Group By 15 minute intervals???

Help.Chris

Registered User.
Local time
Today, 20:56
Joined
Oct 11, 2000
Messages
43
Hi All,

Does anybody know if it is possible to group by hour then 15 minute intervals in a query.

I have date like this

booked cost
15:47 9/7/03 £79.00
17:13 9/7/03 £114.68

I would ideally like to see totals of the cost, but grouped as

8:00 £125.65
8:15 £49.32
8:30 £87.21

and so on depending on the time against the booked time/date

Does anybody know if this is possible and if so how i can do it.

Thanks for any help in advance.

Chris
 
This function will group by 15 minute intervals.

Public Function fHrs(dateIn As Date)

Select Case DatePart("n", dateIn)

Case 0 To 15
Let fHrs = 1

Case 16 To 30
Let fHrs = 2

Case 31 To 45
Let fHrs = 3

Case 46 To 59
Let fHrs = 4

Case Else
MsgBox "Case Error"

End Select

End Function
 
you could use the following query
Code:
SELECT
  CDate(Format([booked],"Short Date"))+
    (CDate(Format([booked],"Short Time"))*1440\15)*15/1440 AS TimePeriod
, Sum(costs) AS SumOfCosts
FROM YourTable
GROUP BY CDate(Format([booked],"Short Date"))+
  (CDate(Format([booked],"Short Time"))*1440\15)*15/1440
 
Last edited:
Thanks,

That was a great help!!!

Is working now fine.

Chris
 

Users who are viewing this thread

Back
Top Bottom