Page 1 of 1

How to get the correct "CENTURY" if from 2-digit Y

Posted: Fri Aug 03, 2007 9:18 am
by UPS
If my date is 03-JAN-07 and I'd like to format it to be YYYY-MMM-DD, is there a way in Datastage for it to automatically put "20" in front of "07" for the year?

My current workaround for this is I do an if-then-else derivation similar to the following:
If datevar[8,2] > 50 then '19' else '20'

Is this another way to get the century???

Posted: Fri Aug 03, 2007 10:36 am
by Bhavesh.Shah
If you can afford a Basic Transformer in your Parallel Job then a combination of Iconv & Oconv can get you the desired results.

Posted: Fri Aug 03, 2007 10:39 am
by chulett
Why not just StringToDate() with the proper mask?

Posted: Fri Aug 03, 2007 12:57 pm
by UPS
I used StringToTimestamp function and was using 'yyyy' for the year for masking. However, for 2-digit '07' as the year, it was populating it with 19 --> so the result was 1907, instead of 2007. What is the proper mask to put the correct century? The on-line documents do not have examples.

Any input is greatly appreciated.

Posted: Fri Aug 03, 2007 1:08 pm
by chulett
Not sure why you get 1907 rather than 2007, but here's what is in the docs:
For a date, the format components are:
%dd two digit day
%mm two digit month
%yy two digit year (from 1900)
%year_cutoffyy two digit year from year_cutoff (e.g. %2000yy)
%yyyy four digit year
%ddd three digit day of the year
The default format is %yyyy-%mm-%dd
Try the 'year_cutoff' version.

Posted: Fri Aug 03, 2007 3:37 pm
by UPS
Thank you! The year_cutoffyy will work! Thanks for your quick reply.

yearcut off works

Posted: Thu Dec 27, 2007 2:32 pm
by sribuz
Thanks craig, I was having same problem with timestamp and after looking at your reply used %2000yy instead of %yy and got the correct output.