There are two dates date1 and date2 that need to be compared in a SQL. If date1 is greater than date2 I would select date1 and compare it in my where clause to be between start-dt and end-dt. If date2 is > than date1 then I would select date2 and compare it to be between start-dt and end-dt in a where clause.
this is how it would go
select <greater of date1 and date2> from .... where <greater of date1 and date2> between (start-dt and end-dt)
I know we can do a if date1 > then ..select and compare date1....
else select date2 and compare date2.
A better way to do it using a function that would return the greater of the two dates.
Can any one help with the function?
Regards,
Naushi Hussain
this is how it would go
select <greater of date1 and date2> from .... where <greater of date1 and date2> between (start-dt and end-dt)
I know we can do a if date1 > then ..select and compare date1....
else select date2 and compare date2.
A better way to do it using a function that would return the greater of the two dates.
Can any one help with the function?
Regards,
Naushi Hussain