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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to say between today and 3 months earlier?

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2010-11-30 : 04:56:43
Hi,

I m using creationdate between DATEADD(yy, DATEDIFF(yy,0,getdate()), 0) and getdate(), for checking if its in a year, but i would like to use between today and 3 months earlier.

Thanks in advance.

Best Regards

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-30 : 05:00:25
if the date then
between dateadd(mm,-3,dateadd(dd,datediff(dd,0,getdate()),0)) and dateadd(dd,datediff(dd,0,getdate()),0)
if datetime you might want
>= dateadd(mm,-3,dateadd(dd,datediff(dd,0,getdate()),0))
and < dateadd(dd,datediff(dd,0,getdate()),0)+1


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -