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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-06-18 : 10:08:22
|
| Leo Campbell writes "I'm having trouble with some date functions in SQL. Here's what I'm trying to do. I'm trying to query a table with a bunch of dates (a lot of them being the same) and return only the ones that will happen/come first. I know I could do a query and do an ascending sort, but that'll return all dates, when I only want that one date.I'll have 5 different events on one date coming next week, 5 more on another particular date coming next month. I want to run my query and it retun the first five events coming next week and not the ones coming next month. Keep in mind I don't know the date so I can't query on that particular date.Please let me know if you could help me out..." |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-06-18 : 10:11:00
|
| select min(eventdate)from eventswhere eventdate > getdate()Duane. |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-06-18 : 11:06:43
|
| Select * From events Where eventdate = (select min(eventdate) from events where eventdate > getdate())Corey |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-18 : 11:42:57
|
| Still kinda foggy about that question...The DDL should clear it up though...It Sounds like you not only want to compare dates between rows, but between columns on the row as wellYes?Brett8-) |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-06-18 : 12:55:34
|
| I thought he wanted the first set of events, meaning: the day of the next occuring events, list all of the events for that date.DDL would help tremendously....Corey |
 |
|
|
|
|
|