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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2010 displaying hours and minutes in a table for summing

Status
Not open for further replies.

BlueHorizon

Instructor
Jan 16, 2003
730
US
Hi everyone,

In an Access table, I want to be able to enter hours and minutes so I can sum them. This is one way the entries could be entered: 1:30 (representing 1 hr/30 min), 1:45 (representing 1 hr/45 min), 2:45, 4:30, etc.

The total/sum could appear as: 10:30 (representing 10 hr/30 min)

I have tried to use the Date/Time data type with different formats but I'm unsuccessful so far.

Is this possible in a table? Many thanks in advance.

Best,
Blue Horizon [2thumbsup]
 


hi,

Understand the distinction between TIME, (in the sense of a point in time, which would include a Date and Time) and DURATION which is the mathematical difference between two points of time or a representation of a passage of time; time being Date and Time.

BTW, Date/Time values are just NUMBERS in units to DAYS. So when you calculate a Date/Time difference (DURATION), it is expressed in days and can be formatted as hours, minutes and days via the Format() function. HOWEVER, if the DURATION represents more than ONE DAY, the Format function wants to show the duration as a DATE & TIME. So you mght need to do something different.

So you are referring to several DURATIONS: D1 + D2 + D3 like this...
Code:
Format(D1 + D2 + D3, "hh:nn:ss")


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Expounding on what skip said, the Date/Time data type is a day and time combined... SO if you use no day (implicitly use a 0 days) when you hit 24 hours you are in day two so Skips example will return unexpected results if you roll past 24 hours with the date/time data type.

You might be better off storing minutes or even seconds depending on your purpose and then writing your own function to format it correctly. A couple tips here... the forward slash in access is integer division or gives you the integer result. The mod (short for modula) operator gives you the remainder.
 
Thank you to both! I'll try your suggestions and get back with results! The info re forward slash and mod is very helpful.

Best,
Kathy

Best,
Blue Horizon [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top