Solved

Rounding duration within 20 min intervals

Posted on 2016-10-19
3
46 Views
Last Modified: 2016-10-19
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 ?
0
Comment
Question by:John-S Pretorius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41850394
Hi,

pls try

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

Open in new window

Regards
1
 

Author Closing Comment

by:John-S Pretorius
ID: 41850419
Perfect Sir, Thank you.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 41850735
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question