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 |
|
seattletype
Starting Member
4 Posts |
Posted - 2009-12-28 : 18:42:44
|
| So I have a SQL server 2000 table setup where it has two datetime fields.. These are events records with a starting and ending date. I need to write a select statement that will show me all events occuring between *today* and EITHER the first date (if the second date field is empty) or.. the second date (that's the "closing" date).Help??? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-12-28 : 20:37:24
|
I don't quite understand your requirement on ofquote: events occuring between *today* and EITHER the first date (if the second date field is empty) or.. the second date (that's the "closing" date).
Maybe you can explain further with examples ?Anyway, this will give you the events starting today.where starting >= dateadd(day, datediff(day, 0, getdate()), 0)and starting < dateadd(day, datediff(day, 0, getdate()), 1) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
seattletype
Starting Member
4 Posts |
Posted - 2009-12-29 : 00:03:07
|
| ok.. so I need to list all of the upcoming events.. so obviously, from today forward... but after "today" passes EITHER datefield1 OR datefield 2 ... in some instances, datefield2 will be empty.. but sometimes it won't... |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-12-29 : 09:06:21
|
| may be this..where starting >= dateadd(day, datediff(day, 0, getdate()), 0)and starting < dateadd(day, datediff(day, 0, ISNULL(DateField1,Datefield2)+1, 1) |
 |
|
|
|
|
|
|
|