Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Fix Date with 0 Padding

Keywords: 	 Fix Date with 0 Padding

Question:

I'm trying to take dates as:
touchdate = "1/1/01 "
touchdate = "1/31/01 "
touchdate = "12/1/01 "
And convert to 8 characters:
01/01/01
01/31/01
12/01/01
Thanks.

Answer:



#DefineFunction fixdate8(d)
   d=StrReplace(d," ","")
   d1=StrFixLeft(ItemExtract(1,d,"/"),0,2)
   d2=StrFixLeft(ItemExtract(2,d,"/"),0,2)
   d3=StrFixLeft(ItemExtract(3,d,"/"),0,2)
   Return(StrCat(d1,"/",d2,"/",d3))
#EndFunction

touchdate = "1/1/01 "
fixeddate=fixdate8(touchdate)
Message(touchdate,fixeddate)

touchdate = "1/31/01 "
fixeddate=fixdate8(touchdate)
Message(touchdate,fixeddate)

touchdate = "12/1/01 "
fixeddate=fixdate8(touchdate)
Message(touchdate,fixeddate)