Finding max of 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
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Finding max of date

Post by dspxlearn »

Hi all,


In one of my requirements i have to find the Max of two dates which are coming from the same input link and got to pass the max value to the output.
If i am not wrong Max() functions works for integer datatypes...Is there any way around to get this...
:oops:
Thanks and Regards!!
dspxlearn
ashwin2912
Participant
Posts: 57
Joined: Wed Jan 26, 2005 10:22 pm
Location: India

Post by ashwin2912 »

You can use > or < if they are of "Date" datatypes.
Ashwin
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I would have expected that a comparison of two variables of type DATE or TIMESTAMP would work - have you tried it? If it doesn't function, then you need to cast the data into a numeric (julian conversion) or a string (formatted YYYYMMDD for collation) so that you can do a comparison.
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Hi ArndW,

Thanks for your earlies reply......

Can you be please more specific....

Let me give my requirement with an example...

Suppose i have a field A which will have two date records with data type Date...

2005-11-21
2005-11-22

The two records i will get from the same column...From this column i need to take the most recent data and i need to pass only this record to the output column....


If i am not wrong
If Link1.col1 > Link1.col1 then Link1.col1 is what you said right...In this case i dont which record will come first....right...
Thanks and Regards!!
dspxlearn
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I misunderstood your original post, I thought you wanted to do a comparison of fields in one row, but you wish to do this across more than one row. In this case the approach is different. If you only have 2 rows across which you want to find the highest, then you can use stage variables to store the previous value and use a comparison; but if your requirements are more complex you will need to use an aggregator (which has builtin MIN/MAX functions).

The question is do you want a MAX of any date in the whole input file, or are you trying to get a maxiumum date in a grouping of records?
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Hi ArndW,


Your idea was good..But i have tried in other way..

I made the transformer into sequential mode and in the input properties i enabled sorting, unique options and taken it in the decending order...Then i took the @outrownum = 1...

Its working fine... :P
Thanks and Regards!!
dspxlearn
Post Reply