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
 produced time

Author  Topic 

gongxia649
So Suave

344 Posts

Posted - 2006-05-05 : 11:24:53
t1
produced_date datetime




how do you select recordsets from 2 days ago?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-05 : 11:26:35
use dateadd()

select *
from t1
where produced_date >= dateadd(day, -2, getdate())



KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-05 : 11:28:16
or use this

where produced_date >= dateadd(day, datediff(day, 0, getdate()), -2)

as the 1st one i post did not cater for time.

KH

Go to Top of Page
   

- Advertisement -