maximum of date

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
DSkkk
Charter Member
Charter Member
Posts: 70
Joined: Fri Nov 05, 2004 1:10 pm

maximum of date

Post by DSkkk »

hi all,
i need to extract the latest date from a column which has datatype as date. this column is extracted from teradata which is in YYYYMMDD. but when i use an aggregator MAX function, then i get an error saying that unable to convert string so taken Null. into which format should the date be converted so that i can extract the maximum value? can anyone suggest?
Thanks in advance.
g.kiran
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

DataStage's 'date' datatype is an integer value identical to Julian date starting from 31st Dec 1969.

You may hence have to convert the date using IConv function. It will be
IConv(YourDate[1, 4] : '-' : IConv(YourDate[5, 2] : '-' : IConv(YourDate[7,2] , 'D-YMD[4,2,2]')

But if the input is directly connected to an aggregator stage, maybe you can try including the MAX into your SQL statement itself.
DSkkk
Charter Member
Charter Member
Posts: 70
Joined: Fri Nov 05, 2004 1:10 pm

Post by DSkkk »

thanks for the immediate response.
my input is not directly connected to the aggregator. so i think i need to use the iconv function. but the ouptut which i get should come only after
the oconv. right!
g.kiran
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Yes. If you need your value back to any other format, you need to use OConv. Format to be used will depend on how you want to use the resulting value.
DSkkk
Charter Member
Charter Member
Posts: 70
Joined: Fri Nov 05, 2004 1:10 pm

Post by DSkkk »

i actually got the maximum of date having YYYYMMDD format. but when i had YYYY-MM-DD it was not able to pick up the maximum. so i used a routine to strip of the extra characters in between and then used the aggregator.
anyway thanks for your attention and help.
g.kiran
Post Reply