date function

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
dudam
Participant
Posts: 11
Joined: Sun Feb 27, 2011 9:40 am

date function

Post by dudam »

My input is 1-dec-2012 datatype varchar i need output like 01-dec-2012
DN
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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".
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dudam
Participant
Posts: 11
Joined: Sun Feb 27, 2011 9:40 am

Post by dudam »

Dear ArndW,

It is working fine,
Thanks for your quick reply

Thanks
DN
Post Reply