Date conversion

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
rumu
Participant
Posts: 286
Joined: Mon Jun 06, 2005 4:07 am

Date conversion

Post by rumu »

Hi All,

I have a requirement to convert input string to date fomat yyyymmdd.
Input string is coming as 'yymmdd' format. Ie if input data is 190110, output should be 20190110.

I used the following conversion:

Code: Select all

DateToString( StringToDate(Lnk_TDCO.TRAIL_DATE,"%yy%mm%dd"),"%yyyy%mm%dd")
The out put I am getting as 19190110..The year is 1919 instead of 2019. How to rectify this?
Rumu
IT Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

For one way, check here and then search for year_cutoff. Allows you to define what is also known as the "Century Pivot".
-craig

"You can never have too many knives" -- Logan Nine Fingers
rumu
Participant
Posts: 286
Joined: Mon Jun 06, 2005 4:07 am

Post by rumu »

Thanks Craig,

To use date tag, do I need to use basic transformer?
Rumu
IT Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Nope, not at all.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rumu
Participant
Posts: 286
Joined: Mon Jun 06, 2005 4:07 am

Post by rumu »

ok, then may be my expression is wrong hence getting parsing error.

If I want to extract cutoff year from the input field, I am using expression as below:

StringToDate(InputLink.Datestring,"%NNNNyy")

I am getting parsing error for this.
Rumu
IT Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I assume you need to replace NNNN with the actual year to use as the cutoff / pivot year.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rumu
Participant
Posts: 286
Joined: Mon Jun 06, 2005 4:07 am

Post by rumu »

Thanks Craig. I set up cut off year as 2000 and received the desired output.
Rumu
IT Consultant
Post Reply