Date Conversion formats

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

aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Date Conversion formats

Post by aasaif »

Hi -
I needed help converting a date format(mm/dd/yyyy hh:mm:ss)
into (dd-MON-YY hh:mm:ss)

i think i have the second part correct
OCONV( ICONV(DSLink2.CreateDate,"D4YMD") ,"D-DMY[2,3A,2] hh:mm:ss")

any help?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Close. Build a small 'test' routine in the Manager to check. Try:

Code: Select all

OCONV(ICONV(Field(DSLink2.CreateDate," ",1,1),"D"),"D-DMY[2,A3,2]") : Field(DSLink2.CreateDate," ",2,1)
Basically, split off the time and then stick it back on the converted date.
-craig

"You can never have too many knives" -- Logan Nine Fingers
aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Post by aasaif »

i tried this still outputing null

OCONV(ICONV(Field(DSLink2.CreateDate,"",1,1),"D"),"D-DMY[2,3A,2] hh:mm:ss")
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right. You need to 'convert' the date portion only and you can't include that time mask in the output conversion. So split into two, convert date, stick time back on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Post by aasaif »

STill null

this is what i have in the transformer
OCONV(ICONV(Field(DSLink2.CreateDate,"",1,1),"D"),"D-DMY[2,3A,2] ")

this is the data
10/29/2008 8:31:00 AM
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Field needs a space as the second (delimiter) argument, so " " not "". And as I posted, it's "A3" not "3A" for a three letter month name.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is no such think as Oconv() for a timestamp. Your second argument is completely wrong. You must convert the date and time portions separately then concatenate them.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Post by aasaif »

Can you help me with how do you parse? Look through help didnt find anything
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just like I posted. Field() can do the parsing for you here. And since your time format is different than you originally posted, you'll need to convert that as well using "MTS".
-craig

"You can never have too many knives" -- Logan Nine Fingers
aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Post by aasaif »

i place the format of the function exactly as you had it
but datastage is otuputing the internal form of the date "14913" am i missing something
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I guess so. Post your latest derivation.
-craig

"You can never have too many knives" -- Logan Nine Fingers
aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Post by aasaif »

here it is

OCONV(ICONV(Field(DSLink2.CreateDate," ",1,1),"D"),"D-DMY[2,A3,2] ")
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Works just fine for me with your posted data:

"10/29/2008 8:31:00 AM" -> "29-OCT-08"
-craig

"You can never have too many knives" -- Logan Nine Fingers
aasaif
Participant
Posts: 98
Joined: Fri Sep 19, 2008 9:12 am

Post by aasaif »

Oh i see what i did wrong i modified the output colum in the transform to datatype of date it was varchar looks good now.

Thank you very much

Now all i got to do is something like this correct
OCONV(ICONV(Field(DSLink2.CreateDate," ",1,1),"D"),"D-DMY[2,A3,2] ") + Field(DSLink2.CreateDate," ",10,8)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use ":" for concatenation, not "+". And you want the 2nd & 3rd "field" for the timestamp part, so Field(DSLink2.CreateDate," ",2,2) to mean "two contiguous fields starting with the 2nd field".
-craig

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