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 |
|
phoeneous
Starting Member
9 Posts |
Posted - 2009-12-03 : 13:32:12
|
| Is it possible to specify an hour when using DATEDIFF? For example this snippet from my query:(DATEDIFF(day, acct_banktran.eff_date, { fn NOW() }) <= 1)I know that this will query all acct_banktran.eff_date that took place yesterday but it pulls all of them starting from 12:00a.m.. How can I limit that query to only get specific acct_banktran.eff_date at a certain hour like 4:15p.m.? Thank you. |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-03 : 13:55:28
|
| Put one more condition as like below(DATEDIFF(day, acct_banktran.eff_date, { fn NOW() }) <= 1) and '2009-12-04 14:30:00.000' < getdate()Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
phoeneous
Starting Member
9 Posts |
Posted - 2009-12-03 : 14:27:58
|
| This is going to be an automated report so there is no manual input of the date. When the report runs, I just need it to always grab yesterdays date at that specific hour. |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-03 : 14:35:57
|
| Make use of getdate()-1 and convert(varchar,getdate()-1,101)+' 14:30:00.000' as datetime)< getdate()Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
phoeneous
Starting Member
9 Posts |
Posted - 2009-12-03 : 16:10:53
|
| Sorry, Im not much of a sql guy, what would the whole query look like? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
phoeneous
Starting Member
9 Posts |
Posted - 2009-12-03 : 17:18:38
|
| No. I meant, what would should the code look like with the snippet I have provided and his suggestion. |
 |
|
|
|
|
|
|
|