Rounding Times

P

Patrick

How would I round the time to let's say, the nearest quarter of an hour. The
value goes down to the second, so at 7 minutes 30 seconds the time would
round up. Example: 7:52:30 AM = 8:00AM or 7:52:29 = 7:45 AM and so on.
This is in Access 97.
 
S

Sergey Poberezovskiy

I do not have '97 version handy, but I'm sure this should
work:

Date+Round((Now-Date)*96 + 0.5, 0)/96

The basic idea is that time is represented as a fraction
and all you have to do is get the number of intervals you
are after in a day:
hours - 24
halves - 48
quarters - 96

HTH
 
Top