Click here to Skip to main content
15,917,731 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i my case i have a Expiredate column and my intention is to get the date before 30 days of Expiredate. how to do that.
Posted

You can do using this:
SELECT DATEADD(day,-30,Expiredate) as LastDate from YourTable
 
Share this answer
 
Comments
Deepu S Nair 18-Feb-15 5:28am    
copy of above solution
Have a look at MSSQLs DATEADD function.

You can use this like:
SQL
SELECT
    DATEADD(day,-30, Expiredate) as 30DaysBeforeExpireyDate
FROM
   tblSource
;


Hope it helps.
 
Share this answer
 
This should work.
C#
select DATEADD(DAY , -30,  GETDATE())
 
Share this answer
 
Comments
hypermellow 18-Feb-15 5:19am    
Beat me to it!

Good answer, have 5 :)
Thanks7872 18-Feb-15 6:31am    
Thanks :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900