Sum of time

  • Thread starter Thread starter Igor G.
  • Start date Start date
I

Igor G.

How to sum times, example:
7:00
2:00
3:00
0:30

In this case result must be: 12:30
Thanks!
 
Time is stored as portion (decimal) of day:




? #07:00# + #02:00# + #03:00# + #00:30#
12:30:00

Assuming you have a 24h preference, not a AM/PM preference, that does the
trick). You will still got problem if the sum exceed 24 hours, though. You
can try:

? 24*( #07:00# + #02:00# + #03:00# + #00:30# +#11:45#)
24.25


to get the result in hours and decimal or hours (0.25 hours = 15 minutes),
or use a format. Note that "nn" is for minutes, "mm" is already used for
month:

? int(24*( #07:00# + #02:00# + #03:00# + #00:30# +#11:45#)) & ":" &
Format(#07:00# + #02:00# + #03:00# + #00:30# +#11:45#, "nn" )
24:15


But then, the result is a string, not a number.




Vanderghast, Access MVP
 
Back
Top