Page 1 of 1
Finding max of date
Posted: Wed Nov 23, 2005 12:14 am
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...
![Embarassed :oops:](./images/smilies/icon_redface.gif)
Posted: Wed Nov 23, 2005 1:15 am
by ashwin2912
You can use > or < if they are of "Date" datatypes.
Posted: Wed Nov 23, 2005 1:16 am
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.
Posted: Wed Nov 23, 2005 3:37 am
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...
Posted: Wed Nov 23, 2005 4:14 am
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?
Posted: Wed Nov 23, 2005 4:46 am
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...
![Razz :P](./images/smilies/icon_razz.gif)