# Rounding duration within 20 min intervals

I have a value (Duration) in Crystal reports that I want to classify in 0-20 minute intervals. i.e. every 20 mins in a day falls within a specific timeframe and gets assigned a value :-

I'm assuming something like below would need to be compiled.
(if duration <= 20 then 1 else if (duration >20 and duration <=40) then 2).....etc, I would need 71 of these.

0 - 20mins = 1
21 - 40mins = 2
41 - 60mins = 3
....................................

1401 - 1420 mins = 70
1421 - 1440 mins = 71

Below duration values would fall within the above mentioned

13mins         (0-20mins) = (1)
507mins       (500 - 520mins) = (26)
907mins       (900-920mins) = (46)
1358mins    (1340-1360mins) = (68)

Is there an easier way to do this in Crystal ?
###### Who is Participating?

Commented:
Hi,

pls try

``````=Fix((YourDuration-0.1)/20, 0)+1
``````
Regards
1

Technical Service Manager, Mid-AtlanticAuthor Commented:
Perfect Sir, Thank you.
0

Commented:
In Crystal there is an integer division operator

This will give you 0 to max
``````{YourDurationField} \ 20
``````

If you want to start at 1 then just add 1
``````{YourDurationField} \ 20 + 1
``````

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.