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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 restrict to fetch data

Author  Topic 

Irfan.abdullah
Starting Member

9 Posts

Posted - 2012-09-19 : 01:18:28
Hi,

restricted to fetch yesterday 7:00 am to today 7:00 am.The field name is dateLoaded, which is a datetime, and displays Date
time in list of values.
DB is sql 2008.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-09-19 : 01:44:11
[code]select *
from yourtable
where dateLoaded >= dateadd(day, datediff(day, 0, getdate()) - 1, '07:00')
and dateLoaded < dateadd(day, datediff(day, 0, getdate()), '07:00')
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -