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 |
dhpeter
Starting Member
3 Posts |
Posted - 2014-12-02 : 13:51:59
|
Hello,I have a database that logs access times form a door. I'm trying to write a query that returns resultswhere DATE between '2014-11-30' and '2014-12-01'and TIME >= 21:00:00 or TIME <= 14:00:00This isn't working. This is displaying the timeframe until 14:00 for both days. My goal is to return results from 21:00 on the 30th to 14:00 on the 1st.When requesting the dates AGAIN in the where clause (IEWhere ( Date = 2014-11-30 and TIME >=21:00:00) or (date = 2014-12-01 and time <= 14:00)This works but is clunky in my front end program.Is there a way to request the time range across the two dates by changing the way we are requesting the times only?The datatype is time, but also behaved the same as varchar |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-12-02 : 15:09:50
|
[code]WHERE [DATE] >= DATEADD(HOUR,21,'20141130') AND [DATE] <= DATEADD(HOUR,14,'20141201')[/code] |
|
|
|
|
|