Date Conversion

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
vj_meghani
Participant
Posts: 7
Joined: Fri Oct 29, 2004 10:48 am

Date Conversion

Post by vj_meghani »

Hi

I am trying to convert date from yyyy/dd/mm to mm/dd/yyyy
I was also trying to convert the timestamp to dd/mm/yyyy.
I am not able to converte it. Can anyone tell what should i do?

vaishali [/code]
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Search this forum for the oft covered ICONV and OCONV functions, as well has how to use substring notation ( variable[x,y] ) and FIELD functions to parse dates.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You may find the article Date Conversion Demystified useful too.

Beware that some stage types convert the date into DataStage internal format (an integer), while other stage types don't. You did not specify which stage type you are using.

Basically, though, if the dates are arriving as character strings, then you can use character string manipulation (substring and concatenation) to rearrange the characters. For example:

Code: Select all

TheDate[9,2] : "/" : TheDate[6,2] : "/" : TheDate[1,4]
A similar technique can be used if the source date is a timestamp.

Alternately you can convert the source date into internal format (if DataStage has not done so already), then back into an appropriate external format. The former uses the Iconv() function, the latter uses the Oconv() function. For example:

Code: Select all

Oconv(Iconv(TheDate, "DYMD"), "D/MDY[2,2,4]")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply