You can round down the time to 15 minute intervals by doing something like this, where the last column will show the rounded time:SELECT *, DATEADD(mi,DATEDIFF(mi,0,YourDateColumn )/15*15,0) as RoundedTimeFROM YourTable
If you want to pick data only for any particular 15 minute slot, you could then specify that in the where clause, for example:SELECT *, DATEADD(mi,DATEDIFF(mi,0,YourDateColumn )/15*15,0) as RoundedTimeFROM YourTableWHERE DATEADD(mi,DATEDIFF(mi,0,YourDateColumn )/15*15,0) as RoundedTime = '2011-05-25 07:15:00.000'
That would pick all the rows where time is between 7:15 and 7:30.If you want to add a slot number to your query you can do the following:SELECT *, DATEADD(mi,DATEDIFF(mi,0,YourDateColumn )/15*15,0) as RoundedTime, DATEDIFF(mi,DATEADD(dd,DATEDIFF(dd,0,YourDateColumn ),0),YourDateColumn )/15 as SlotNumberFROM YourTable
Here I have added a column to show the 15 minute slot number which would go from 0 to 95. Then, you could use that in your where clause if you prefer etc. etc.