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 |
|
dotnetdns@hotmail.com
Starting Member
4 Posts |
Posted - 2008-03-29 : 22:31:34
|
| Trying to construct a sql statement that would return a record set thet contained the records that were inserted 18 hours go. Using the insertDate field which is defaulted to getdate() so it returns a value similar to "1/2/2008 8:59:27 AM". Here is what I have: rs.Open "SELECT * FROM this_view where insertDate=' " & Now -18 hours & " ' " Need to gather all the records that are in the hour that occured 18 hours ago. Thanks for taking a look,Doug |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-03-29 : 22:38:16
|
| Use dateadd function like dateadd(hh, -18, getdate()). |
 |
|
|
dotnetdns@hotmail.com
Starting Member
4 Posts |
Posted - 2008-03-29 : 22:52:11
|
| Thanks, This should work right?Select * FROM email_view WHERE InsertDate >=DATEADD(hh, -18, GETDATE())AND InsertDate < DATEADD(hh, -19, GETDATE()) order by insertDate |
 |
|
|
dotnetdns@hotmail.com
Starting Member
4 Posts |
Posted - 2008-03-29 : 23:18:02
|
| any idea why SELECT count (*) as total FROM email_view WHERE InsertDate >=DATEADD(hh, -36, GETDATE())AND InsertDate < DATEADD(hh, -19, GETDATE()) returns 456 in sql QA but 0 in wsh??? |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-03-29 : 23:20:42
|
| I think should use this:Select * FROM email_view WHERE InsertDate >= DATEADD(hh, -19, GETDATE()) AND InsertDate < DATEADD(hh, -18, GETDATE()) |
 |
|
|
dotnetdns@hotmail.com
Starting Member
4 Posts |
Posted - 2008-03-30 : 00:03:25
|
| Got it,Thanks for your help!Doug |
 |
|
|
|
|
|
|
|