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 - 2001-10-26 : 09:48:33
|
| Evan writes "I have two semi-related questions about selecting records based on date/time information.First:I have a table where each row contains a start and end date. I need to build a query that will select rows where the current system date falls in between the Table.StartDate and Table.EndDate values. I've done this in Access quite a bit by using Access' built-in Now() function: SELECT * FROM Table WHERE (Table.StartDate <= Now() AND Table.EndDate >= Now()). I've made the unfortunate discovery that I can't use the SQL Server GETDATE() function in the same way. How then, can I accomplish this same result?Second: How can I extend this problem when there is date and time information stored in seperate tables? Table1 contains one date per row, plus a numerical link field. Table 2 contains a corresponding numerical link field per row, plus StartTime and EndTime fields. Table1 has a one-to-many relationship with Table2 (they're part of a scheduling system). I am having real trouble even figuring out where to start in constructing a query that will get the current system date and time, then select a distinct row from Table2 where the system date = Table1.Date AND the current system time falls between Table2.StartTime and Table2.EndTime.Thanks for helping a novice!" |
|
|
|
|
|