numbers

  • Thread starter Thread starter Bill H.
  • Start date Start date
B

Bill H.

I have a database of call times, and I want to round up the time (in secs)
to the next higher multiple of 6.

Is there an easy way to do this?

How?

Thanks!
 
I have a database of call times, and I want to round up the time (in secs)
to the next higher multiple of 6.

What's the datatype of the field? I'd suggest using Long Integer
seconds and using an expression such as

6*Fix([duration] / 6) + IIF(Fix([duration] / 6) < [duration] / 6, 1,
0)
 
datatype is long.

John Vinson said:
I have a database of call times, and I want to round up the time (in secs)
to the next higher multiple of 6.

What's the datatype of the field? I'd suggest using Long Integer
seconds and using an expression such as

6*Fix([duration] / 6) + IIF(Fix([duration] / 6) < [duration] / 6, 1,
0)
 
doesn't seem to quite work. Here's some numbers:

value value after formula
59 55
85 85
108 108
183 181
275 271


John Vinson said:
I have a database of call times, and I want to round up the time (in secs)
to the next higher multiple of 6.

What's the datatype of the field? I'd suggest using Long Integer
seconds and using an expression such as

6*Fix([duration] / 6) + IIF(Fix([duration] / 6) < [duration] / 6, 1,
0)
 
Try this:

6 * CLng(duration / 6)

Or, if you don't like that kind of rounding:

6 * Fix(Duration / 6 + .5 * Sgn(Duration))
--
Marsh
MVP [MS Access]


doesn't seem to quite work. Here's some numbers:

value value after formula
59 55
85 85
108 108
183 181
275 271


John Vinson said:
I have a database of call times, and I want to round up the time (in secs)
to the next higher multiple of 6.

What's the datatype of the field? I'd suggest using Long Integer
seconds and using an expression such as

6*Fix([duration] / 6) + IIF(Fix([duration] / 6) < [duration] / 6, 1,
0)
 
I think John meant the formula:

6*( Fix([duration] / 6) + IIF(Fix([duration] / 6) < [duration] / 6, 1,0) )

Note the extra set of brackets. Another alternative id duration is ALWAYS >
0:

( ([Duration] - 1) \ 6 + 1 ) * 6
 
doesn't seem to quite work. Here's some numbers:

value value after formula
59 55
85 85
108 108
183 181
275 271

hmmm... rounding wasn't working as I expected! Try:

6*Fix([duration] / 6) + IIF([Duration] MOD 6 > 0, 1, 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top