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???
How to get the correct "CENTURY" if from 2-digit Y
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 4
- Joined: Fri May 25, 2007 9:20 am
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.
Any input is greatly appreciated.
Not sure why you get 1907 rather than 2007, but here's what is in the docs:
Try the 'year_cutoff' version.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
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
yearcut off works
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.
Thanks & Regards,
Sri
Sri