SQL - Break a start/end time into 15 minute records
- by Chu
I've got a record set that consists of a start and end time in two separate fields:
id - Int
startTime - DateTime
endTime - DateTime
I'd like to find a way to query a record and return it as X records based on the number of 15 minute intervals found between the start and end times.
For example, let's say I have a record like this:
id, StartTime, EndTime
1, 1/1/2010 8:28 AM, 1/1/2010 8:47 AM
I would return 3 records, the first would represent the 8:15 interval, #2 for the 8:30 interval and then a 3rd for the 8:45 interval.
I realize this could be done using logic in an sproc, but we are trying to remain db neutral as we support multiple database engines.