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.
| Author |
Topic |
|
dutyfree
Starting Member
5 Posts |
Posted - 2007-09-03 : 05:14:43
|
| I have a table with a field "StartedAt". I wish to capture all the data in that table which has Yestarday's StartAt date.My script below captures the data which has yestardays "StartedAt" info as well as today's date till now. How can i capture only yestardays info only.SELECT StartedAt FROM myTableWHERE StartedAt >= DATEADD(day, DATEDIFF(day, 0, getdate()), -1) please help. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-09-03 : 05:16:57
|
| add an upper boundry:WHERE StartedAt >= DATEADD(day, DATEDIFF(day, 0, getdate()), -1) and StartedAt < DATEADD(day, DATEDIFF(day, 0, getdate()), 0)_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2007-09-03 : 05:18:09
|
| [code]SELECT StartedAt FROM myTableWHERE StartedAt >= DATEADD(day, DATEDIFF(day, 0, getdate()), -1) AND StartedAt < DATEADD(day, DATEDIFF(day, 0, getdate()), 0)[/code]Mark |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2007-09-03 : 05:22:45
|
Mark |
 |
|
|
dutyfree
Starting Member
5 Posts |
Posted - 2007-09-03 : 05:23:57
|
| Thanks very much guys. Made my life easier. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-03 : 05:50:01
|
| www.sql-server-perfromance.com/fk_datetime.aspMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|