Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding to the nearest 15 min

Status
Not open for further replies.

DJMIKEDEE

Technical User
May 17, 2002
4
0
0
DE
Hello helping hand(s)

As a new Crystal Reports user, I am trying to round to the nearest 15 min, but we use the industrial clock ie 15 min=0,25____30 min=0,5 and 45 min=0,75

for example some one who works 38hour and 30 minutes in one week would be calculated as 38,5hours

but sometimes we have parttimers that only work, say, 18 hours a week which have to calculated like this

18(hours)/5(days of week)=3,6*19(workingdays)=64,4 rounded up should be 64,5
or
22(hours)/5(days of week)=4,4*22(workingdays)=96,8 rounded down should be 96,75 and so on

is there any body out there that can help me???

Thanks for the help in advance

Michael Robbins
DJMIKEDEE@aol.com
 
If I was tackling this, I would probably do a formula looking something like:

numbervar Calc := ((hours)/(days of week))*(workingdays)
numbervar Remainder := tonumber(right(totext(Calc,2,""),2))
if Remainder >= 0 and Remainder <=15 then tonumber(totext(truncate(calc),0,&quot;&quot;)&&quot;.&quot;&&quot;15)
etc, etc, etc.

Sorry if this isn't the best way to do it, I'm sure one of the &quot;professionals&quot; will respond to this post pretty quickly.
Reebo
Scotland (Going mad in the mist!)
 
Here are the steps I would take:
(1) multiply the actual value by 4
(2) round the result to the nearest whole number
(3) divide the rounded value by 4


For example:
(1) 64.4 * 4 = 257.6
(2) 257.6 => 258.0
(3) 258.0 / 4 = 64.50

(1) 96.8 * 4 = 387.2
(2) 387.2 => 387.0
(3) 387.0 / 4 = 96.75

Hope this helps,
Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top