BHScripter
Technical User
Hi:
In my where clause I need to choose records based on a particular date to compare against two date columns. If the date from the database is older than getdate() than I want to compare getdate() against the two date columns if the date is newer (or in the future) than getdate() I want to use the database date.
I tried the following knowing it wasn't quite right - but I could hope. Any help would be appreciated.
case when tbl1.dtready < getdate() then between tbl2.dtstartdate and tbl2.dtenddate else getdate() between tbl1.dtstartdate and tbl2.dtenddate end
In my where clause I need to choose records based on a particular date to compare against two date columns. If the date from the database is older than getdate() than I want to compare getdate() against the two date columns if the date is newer (or in the future) than getdate() I want to use the database date.
I tried the following knowing it wasn't quite right - but I could hope. Any help would be appreciated.
case when tbl1.dtready < getdate() then between tbl2.dtstartdate and tbl2.dtenddate else getdate() between tbl1.dtstartdate and tbl2.dtenddate end