I have the following (which I know is syntactically incorrect, maybe even bearing on ridiculous):
and lp.lease_current_stop_date
case when @lease_expiry_period = 01
then
between dateadd(MONTH, +1,
getdate())
else
between dateadd(MONTH, +2,
getdate())
I’m just wondering what would be the best way to accomplish this? What I’m trying to do with the above is:
*When @lease_expiry_period is equal to 01 then show all leases expiring up to a month from now. When @lease_expiry_period is equal to 02 then show all leases expiring up to two months from now.*
Performance note
Worth noting that I didn’t truncate the date in my example for simplicity also. As this is using month getdate() should be:
Dateadd(d,0,datediff(d,0,getdate()))
For best performance.
1 Answer