Issue with Loading Date

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
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Issue with Loading Date

Post by velagapudi_k »

I have this situation. Source is a csv file. I am reading everything as varchar and trying to load to Teradata. There is a column which has dates, from the source. In the transfomer I am doing a StringToDate(IP,'yyyy-mm-dd'). Issue is for 01/01/01 it is loading as 1901-01-01 instead of 2001-01-01. Is there any way other than padding the string and then converting to date. Any thoughts are appreciated.
Venkat Velagapudi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Read up about format strings and about century pivot.

You can, in fact, combine the two. For example, a format string of "2000yy-mm-dd" will force the century part of the year to be "20".

Where you only have two digit years you will definitely need to specify the century pivot year to something other than its default (1930).
Last edited by ray.wurlod on Tue Jan 08, 2013 1:34 am, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

As told by Ray, either use $APT_DATE_CENTURY_BREAK_YEAR variable in your job parameters or using the below code in transformer while doing conversion
StringToDate(<date>, "%2000yy-%mm-%dd")
Thanx and Regards,
ETL User
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

Thanks for the input folks. $APT_DATE_CENTURY_BREAK_YEAR did the trick. Guess its added in 8.7
Venkat Velagapudi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No, it's been there since at least version 7.5.
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