How to change Date format change from YYYY-MM-DD to YY-MM-DD

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
rkumar28
Participant
Posts: 43
Joined: Tue Mar 30, 2004 9:39 am

How to change Date format change from YYYY-MM-DD to YY-MM-DD

Post by rkumar28 »

Hi,

I am new to DataStage. I am looking for an available function to change the date format from YYYY-MM-DD to YY-MM-DD. Actually my source flat file has the YYYY-MM-DD format but my target teradata table has a column that has Date datatype and is defined to take YY-MM-DD date format.

Thanks
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

Use ICONV and OCONV to convert it to the new format. SOmething like:

OCONV(ICONV(DateValue, "D-YMD[4,2,2]"), "D-YMD[2,2,2]")
jseclen
Participant
Posts: 133
Joined: Wed Mar 05, 2003 4:19 pm
Location: Lima - Peru. Sudamerica
Contact:

Re: How to change Date format change from YYYY-MM-DD to YY-M

Post by jseclen »

Hi, the other way is use substrings

Your format --> 'YYYY-MM-DD'

Value = DateField[2,8]

Example:

'1999-04-02' applying DateField[2,8]

Value='99-04-02'

Saludos.

:lol:
Saludos,

Miguel Seclén
Lima - Peru
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or you can even use the "rightmost substring" to return the rightmost eight characters (remember that there are no data types within DataStage). There are two syntaxes:

Code: Select all

DateField[8]
Right(DateField,8)
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