Good morning everyone, thanks for taking the time out of your day to assist with my question.I have been trying to figure this out for a few days. I need to be able to query overlapping dates in my sql database, for example. Lets say someone requested a water pump to run from 1/20/2012 5:15pm to 1/25/2012 5:15PMand someone else wanted to run the same pump from 1/22/12 8:AM to 1/22/2012 4:PMhow would I query the data so I could see that the pump was already in use on the 22nd day? Here is what I currently have but it does not work.SELECT SUM(flow_gpm) as gpmTotal FROM water_request WHERE (TO_start_time BETWEEN '01/22/2012 8:00:00 AM' AND '01/22/2012 4:00:00 PM') OR (TO_end_time BETWEEN '01/22/2012 8:00:00 AM' AND '01/22/2012 4:00:00 PM
The only thing this query succeeds in is noticing the other pump request if one of the dates falls in the specified range. Example:SELECT SUM(flow_gpm) as gpmTotal FROM water_request WHERE (TO_start_time BETWEEN '01/25/2012 2:00:00 PM' AND '01/25/2012 10:00:00 PM') OR (TO_end_time BETWEEN '01/25/2012 2:00:00 PM' AND '01/25/2012 10:00:00 PM')
If I need to clarify please let me know, thank you very much.