425,460 Members | 2,215 Online
Need help? Post your question and get tips & solutions from a community of 425,460 IT Pros & Developers. It's quick & easy.

# How can I calc a percentage of an hour?

P: 49
Access 2010:

I need to calc the difference between two times then calc a percentage of an hour?

Expand|Select|Wrap|Line Numbers
1. !StartTimeStamp1 = StartTime
2. !EndTimeStamp1 = MDrs("TimeStamp1")
3. !Total_time = MDrs("TimeStamp1") - StartTime
First problem, the above code is giving the following result, adding 12 hours when the difference is less than one hour. See attachment.

Second problem I cannot find a good example to calc a percentage of an hour. i.e. if the above field "Total_time" = 29:51 then I want to calc 29:51 / 60:00 = .4975

Hope I explained my problem correctly
Attached Images
 Time Example.jpg (29.0 KB, 341 views)
Mar 16 '12 #1

The results are correct. 12:29:51 AM is 29:51 minutes from time 0 which is 12:00 AM, or in 24 hour format, 00:00:00. In 24 hour format, it's 00:29:51. In 12 hour format, it's 12:29:51. There is also a date component that you don't see.

You seem to think that there is a time only data type. There is no such data type. They are all date AND time data, even if you don't display one or the other.

To calculate a percentage of the hour, Get the number of minutes, multiply by 60, add the number of seconds, then divide by 3600. That's if you want it down to the precision of a second. If you just care about the minutes, take the number of minutes and divide by 60. Use the DATEPART function to grab a section of a date time field.

 Expert Mod 10K+ P: 12,355 The results are correct. 12:29:51 AM is 29:51 minutes from time 0 which is 12:00 AM, or in 24 hour format, 00:00:00. In 24 hour format, it's 00:29:51. In 12 hour format, it's 12:29:51. There is also a date component that you don't see. You seem to think that there is a time only data type. There is no such data type. They are all date AND time data, even if you don't display one or the other. To calculate a percentage of the hour, Get the number of minutes, multiply by 60, add the number of seconds, then divide by 3600. That's if you want it down to the precision of a second. If you just care about the minutes, take the number of minutes and divide by 60. Use the DATEPART function to grab a section of a date time field. Mar 16 '12 #2