Page 1 of 1
date function
Posted: Mon Dec 24, 2012 1:25 am
by dudam
My input is 1-dec-2012 datatype varchar i need output like 01-dec-2012
Posted: Mon Dec 24, 2012 4:44 am
by ArndW
Is the output also varchar? If so,
Code: Select all
Right( '00':Field(In.String,'-',1),2):'-':Field(In.String,'-',2,2)
might do what you want.
Field(In.String,'-',1) takes everything from the beginning of the string to the first '-', i.e. "1" in your example
'00':"1" makes a string "001"
Right("001",2) makes a 2 long string, "01"
Field(In.String,'-',2,2) takes the last 2 fields delimited by '-', in this case "dec-2012"
and finally they are all concatenated to "01-dec-2012".
Posted: Mon Dec 24, 2012 9:30 am
by chulett
I would think you could string together a StringToDate() followed by a DateToString() with the proper format masks. Assuming a varchar target, as Arnd notes.
Posted: Wed Dec 26, 2012 1:57 am
by dudam
Dear ArndW,
It is working fine,
Thanks for your quick reply
Thanks