how to convert varchar to date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sureshchandra
Participant
Posts: 92
Joined: Mon May 07, 2007 4:26 am

how to convert varchar to date

Post by sureshchandra »

Hi all,
How to convert 2008-08-10 07:53:08:230 into yyyy-mm-dd
(2008-08-10).Please....

Regards
suresh
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's not a lot of true 'converting' in Server, it is very forgiving. Here, since your format is correct, you can either substring the date portion or use Field() to get it:

Code: Select all

YourField[1,10] -or- Field(YourField," ",1,1)
-craig

"You can never have too many knives" -- Logan Nine Fingers
sureshchandra
Participant
Posts: 92
Joined: Mon May 07, 2007 4:26 am

Post by sureshchandra »

Hi,
Thanks for your response.For yyyy-mm-dd i'm using as "D YMD[4,2,2]"
Can you help me in converting this format (yyyy/mm/dd hh:mm:ss)
as yyyy/mm/dd.

thanks
suresh
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Again, there's no "coversion" needed here, just a substring to remove the time portion. :?

And you would use "D-YMD[4,2,2]" for "yyyy-mm-dd". Note the dash between the "D" and the "M" to match the delimiter needed/used.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply