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 |
|
ramdas
Posting Yak Master
181 Posts |
Posted - 2004-06-03 : 10:45:21
|
| Hi,I have a table called tbl_a with the following definitiontbl_a(a_id int, b_days int, c_id int, date_time datetime)The date_time column has both time information correspoding to every half hour. For example like 2004-05-03 01:00:00.000, 2004-05-03 01:30:00.000. I want to write query which would return records for the latest half hour interval. For example if the current date and time is 2004-05-03 10:35:00.000, i would like to have the data in the table which range from 2004-05-03 9:30 to 2004-05-03 10:00 AM.Any ideas/suggestions.RamdasRamdas NarayananSQL Server DBA |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-06-03 : 11:50:42
|
| maybe this:select * from tbl_awhere date_time between (select top 1 date_time from tbl_a where date_time < @CurrentDate) and (select top 1 date_time from tbl_a where date_time > @CurrentDate)Go with the flow & have fun! Else fight the flow :) |
 |
|
|
|
|
|