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
 date diff

Author  Topic 

craigmacca
Posting Yak Master

142 Posts

Posted - 2008-10-20 : 08:39:52
Hi whats the best way to get a select where date field is more than 3 months old i have tried the following

<> DATEDIFF(month, getdate(), (month(getdate())-1))

not sure if this is correct?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-20 : 09:09:28
<=dateadd(month,-3,getdate())

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-20 : 09:43:24
and if you want records till last day end use this

<=dateadd(month,datediff(month,0,getdate())-3,0)
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-10-21 : 07:14:54
hi visakh,
wats the difference between ur query and above one?
Go to Top of Page
   

- Advertisement -