Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have table will rows like below:

MSIL
Auto_id       st_date            End_Date
1       2011-01-20 10:05:00       2011-01-20 10:30:00
2       2011-01-20 10:31:00       2011-01-20 10:55:00
3       2011-01-20 10:56:00       2011-01-20 11:30:00


Now, from above table i want to list row where time is 2011-01-20 10:45:00 i.e. 2 row of the above table.
Can anyone help me with query.
Thanks
Posted
Updated 18-Jan-11 1:15am
v4
Comments
Blesson Mathew 18-Jan-11 6:12am    
Edited for removing the question part from code block

Ok I tried complete work for you and got suceed.

Take a look at complete query

SQL
create table TestDTbetween
(
autoid int,
start datetime,
enddate datetime
)

insert into TestDTbetween
select 1,'2011-01-20 10:05:00','2011-01-20 10:30:00'
union all
select 2,'2011-01-20 10:31:00','2011-01-20 10:55:00'
union all
select 3,'2011-01-20 10:56:00','2011-01-20 11:30:00'


select * from TestDTbetween where '2011-01-20 10:45:00' >= start AND '2011-01-20 10:45:00' <= enddate
 
Share this answer
 
Comments
Manfred Rudolf Bihy 19-Jan-11 16:01pm    
Take my 5+!
Try this -
SQL
SELECT *
FROM yourtable
WHERE @time between st_date AND end_date
 
Share this answer
 
Comments
Sushma_Patel 18-Jan-11 6:18am    
Thanks Prerak
Espen Harlinn 18-Jan-11 7:18am    
5+ Nice and simple, a good answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900