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 function

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2009-01-09 : 13:00:38
Hi Group:

Quick question...

How can I select only information from 60 days to the present date?

getdate()-60

Thanks for the help!!!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-09 : 13:02:35
[code]select * from table where datefield>getdate()-60 and datefield<=getdate()[/code]
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-01-09 : 13:07:59
DATEADD(dd,-60,getdate())

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2009-01-09 : 13:36:39
Thank you
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-01-09 : 22:39:57
select * from urtable where datefield BETWEEN DATEADD(d,DATEDIFF(d,0,GETDATE()-60),0)
AND DATEADD(d,DATEDIFF(d,0,GETDATE()),0)
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-01-09 : 22:46:39
select * from table where datefield>dateadd(d,datediff(d,0,getdate()-60),0) and datefield<=dateadd(d,datediff(d,0,getdate()),0)


Jai Krishna
Go to Top of Page
   

- Advertisement -