Link to home
Start Free TrialLog in
Avatar of John-S Pretorius
John-S PretoriusFlag for United States of America

asked on

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 ?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John-S Pretorius

ASKER

Perfect Sir, Thank you.
Avatar of Mike McCracken
Mike McCracken

In Crystal there is an integer division operator

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

Open in new window


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

Open in new window


mlmcc