WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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)



Article ID:   W15722
File Created: 2003:05:28:10:23:42
Last Updated: 2003:05:28:10:23:42