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 table as following:--StudentID Name CertiDate-------------------------1 abc 01-01-20002 qwe 01-01-20093 asd 12-25-2010I want output next due date of CertiDate which will be after 180 days. I am getting it through following query:SELECT ID, Name, CertiDate, DATEADD(dd, 180, CertiDate) AS NextDueDateFROM Studentbut if NextDueDate is less than today's date then in NextDueDate I want Today's Date
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2011-01-24 : 10:48:40
you mean this?
SELECT ID, Name, CertiDate, CASE WHEN DATEADD(dd, 180, CertiDate) < GETDATE() THEN GETDATE() ELSE DATEADD(dd, 180, CertiDate) END AS NextDueDateFROM Student
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
vinaym
Starting Member
8 Posts
Posted - 2011-01-24 : 11:39:27
Yes Exactly....Thanks visakh16
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2011-01-24 : 11:40:51
wc ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/