Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have a where class that compares an expiration date to the current date, so I don't pull expired data. I am wondering if there is any way to write something that could 'change' the expiration date (in the query check only, not the actual table) that if the date falls on a saturday or sunday, the expiration date would be the preceeding fri.My where clause is: WHERE ExpDate > GETTDATEIs it possible to do something like this: WHERE IF(datepart(expdate)=*,expdate=*)...Sorry, I am more into excel programming at the moment.
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2010-02-20 : 11:39:47
If you want to change ExpDate, try
WHERE dateadd(day,case when datename(weekday,ExpDate)='Saturday' then -1 when datename(weekday,ExpDate)='Sunday' then -2else 0end,ExpDate)> GETTDATE
PS : The above will work only if the default language of the Server is EnglishMadhivananFailing to plan is Planning to fail