How can I round seconds [easy]

  • Thread starter Thread starter Guest
  • Start date Start date
I want to round seconds on a field. How can this be done?

Context? What's the datatype of the field? What does it contain now,
and what do you want it rounded *to*?

Note that an Access Date/Time field is already rounded to seconds; you
cannot display finer time intervals.

John W. Vinson[MVP]
 
I have a long time field, however for my calculations to work in later fields
I need it to round down from seconds. I have a time for 12:04:29, the field
will only show "12:04", but I want it to permanently be "12:04" so that
calculations later to value 0:00 instead of 0:00:49. I am left with a time
balance. The problem is that when I have large amounts of time data there
may be 2 or 3 minutes added to the equation because it is taking seconds into
consideration. I want to eliminate this.
 
I have a long time field, however for my calculations to work in later fields
I need it to round down from seconds. I have a time for 12:04:29, the field
will only show "12:04", but I want it to permanently be "12:04" so that
calculations later to value 0:00 instead of 0:00:49. I am left with a time
balance. The problem is that when I have large amounts of time data there
may be 2 or 3 minutes added to the equation because it is taking seconds into
consideration. I want to eliminate this.

Ok... so you want to round to the next lowest *minute*. You didn't say
that; you said "round seconds" which (to me) means round to the
nearest second.

Try CDate(Format([timefield], "hh:nn"))

This will parse the time to a hours/minutes text string and convert
that back to a Date/Time, losing the seconds in the process. From the
Immediate window:

?CDate(format(#12:25:45#, "hh:nn"))
12:25:00 PM


John W. Vinson[MVP]
 
Back
Top