June 7, 2013 at 1:19 pm
So, say I have a record where StartTime is '2013-06-07 13:00:00.000' and EndTime is '2013-06-07 13:02:00.000'
Is there a way to have T-SQL select this record if I'm querying for time between StartTime and EndTime that is '2013-06-07 13:01:00.000'? Essentially I'm looking for all records where StartTime and EndTime overlap with the time I'm querying for.
I can't figure out the syntax for it, and I'm not having any luck searching for it.
Thanks for any help you can provide!
June 7, 2013 at 1:30 pm
tmac25 (6/7/2013)
So, say I have a record where StartTime is '2013-06-07 13:00:00.000' and EndTime is '2013-06-07 13:02:00.000'Is there a way to have T-SQL select this record if I'm querying for time between StartTime and EndTime that is '2013-06-07 13:01:00.000'? Essentially I'm looking for all records where StartTime and EndTime overlap with the time I'm querying for.
I can't figure out the syntax for it, and I'm not having any luck searching for it.
Thanks for any help you can provide!
...
WHERE
@SearchDateTime between StartTime and EndTime -- where StartTime and Endtime are the actual column names in the table
...
June 7, 2013 at 3:55 pm
Lynn Pettis (6/7/2013)
tmac25 (6/7/2013)
So, say I have a record where StartTime is '2013-06-07 13:00:00.000' and EndTime is '2013-06-07 13:02:00.000'Is there a way to have T-SQL select this record if I'm querying for time between StartTime and EndTime that is '2013-06-07 13:01:00.000'? Essentially I'm looking for all records where StartTime and EndTime overlap with the time I'm querying for.
I can't figure out the syntax for it, and I'm not having any luck searching for it.
Thanks for any help you can provide!
...
WHERE
@SearchDateTime between StartTime and EndTime -- where StartTime and Endtime are the actual column names in the table
...
I can't believe it was that simple, thank you!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy