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 |
mxfrail
Yak Posting Veteran
84 Posts |
Posted - 2008-08-29 : 10:42:10
|
I am trying to run a query every night that includes a where clause like this -Date between Todays date 00:00:000 and getdate()So basically running a between off the first midnight of that day against whatever time date is when its run.any suggestions? |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-29 : 10:44:14
|
SELECT DATEADD(d, DATEDIFF(d, 0, GetDate()), 0), GetDate()_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-29 : 10:46:32
|
[code]SELECT * FROM YourTableWHERE datefield>=DATEADD(d,DATEDIFF(d,0,GETDATE()),0)AND datefield<DATEADD(d,DATEDIFF(d,0,GETDATE())+1,0)[/code] |
 |
|
mxfrail
Yak Posting Veteran
84 Posts |
Posted - 2008-08-29 : 10:51:30
|
That was quick!Thank you |
 |
|
mxfrail
Yak Posting Veteran
84 Posts |
Posted - 2008-08-29 : 10:58:24
|
In anyone wondered -I ended up using this between DATEADD(d, DATEDIFF(d, 0, GetDate()), 0) and GetDate() |
 |
|
|
|
|
|
|