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 2000 Forums
 Transact-SQL (2000)
 Results for yesterdays date

Author  Topic 

AnaBanana
Starting Member

2 Posts

Posted - 2006-05-24 : 03:33:57
Hi,

I'm writing a query which will look at a datetime stamp and needs to look at only yesterday's date (not time). Can you provide some advice please?

Thanks heaps, Ana :)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-24 : 04:14:35
[code]
Select columns from yourTable
Where
Datecol>=DateAdd(day,Datediff(day,0,getdate()),-1)
and Datecol<DateAdd(day,Datediff(day,0,getdate()),0)
[/code]

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-24 : 04:15:04
[code]
where datecol >= dateadd(day, datediff(day, 0, getdate()), -1) -- yesterday 00:00
and datecol < dateadd(day, datediff(day, 0, getdate()), 0) -- today 00:00
[/code]


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-24 : 04:16:04
Again !


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-24 : 04:18:46
quote:
Originally posted by khtan

Again !


KH




Now-a-days you are typing slowly

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-24 : 04:26:13
"Now-a-days you are typing slowly"
I blame it on the keyboard


KH

Go to Top of Page

AnaBanana
Starting Member

2 Posts

Posted - 2006-05-24 : 20:12:11
Thanks heaps guys :)
Go to Top of Page
   

- Advertisement -