Grouping times into half hour periods

Saturday 25 January 2020 @ 9:37 pm

When you create a group in Crystal using a Date field you get grouping options for different periods like by day, week or month. If the field is a Time or DateTime you get options like by Hour, by minute or AM/PM. But there isn’t an automatic option to group on the half hour.

Below is a formula that will divide all the time values in an hour into two groups. For example, it will turn all time values between 6:00 and 6:29 into 06:00. It will, and will turn all time values between 6:30 and 6:59 into 06:30. You can use this for creating groups, charts or cross-tabs.  Note that the leading zero will keep the groups in the chronological order.

Totext (Hour({@time}),'00') &
(if Minute({@time}) < 30
then ':00'
else ':30')

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)

Leave a Reply

Recrystallize Pro

Crystal Reports Server