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 |
|
KingCarlos
Yak Posting Veteran
74 Posts |
Posted - 2009-10-25 : 22:38:40
|
| Hi, I am trying to have a report built which gets the next_call_date a day before the next call date. In otherwords the report is run today, October 26 2009 and I want it to capture all data that has the value of October 27 2009.And then the day after October 27 2009 and I want it to capture all data that has the value of October 28 2009.How do I build such a sql query |
|
|
KingCarlos
Yak Posting Veteran
74 Posts |
Posted - 2009-10-25 : 22:56:57
|
| Actually thinking I can have it built on the same date earlier monring so that the report can be sent before office hoursThe problem with this SQL Script is that the getdate includes the time whereas the next_call_date format is YYYY-DD-MMselect next_call_date, * from contactswhere next_call_date = getdate()I was also fooling arou8nd with this sql scriptselect next_call_date, * from contactswhere next_call_date = dateadd (d,1,getdate()ltrim,10)) |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-10-25 : 23:28:45
|
| where next_call_date = dateadd(day, datediff(day, 0, getdate()), 1) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-25 : 23:47:38
|
[code]where next_call_date >= dateadd(day, datediff(day, 0, getdate()), 1)and next_call_date < dateadd(day, datediff(day, 0, getdate()), 2)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
KingCarlos
Yak Posting Veteran
74 Posts |
Posted - 2009-10-26 : 00:27:24
|
| thanks russel your solution worked a trest !!! Hi khtan I will try yours also, thanks !! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-26 : 00:29:49
|
if you next_call_date contains time, then you have to use the query i posted, if not russell's query is sufficient KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|