Presenting Time in Hours and tenths

JReichnan

Registered User.
Local time
Today, 16:41
Joined
Oct 28, 2005
Messages
33
I created a time clock module where you input the time in and time out and it takes the difference of the two to give total time worked. However the boss wants the time worked represented in hours and tenths of hours not minutes. How can I take the time, seperate the hours...find out how many tenths of an hour worked and then add the hours and tenths together.
 
Please post the code you are using to return the hours and minutes.
 
and stop posting duplicate threads in different sections.
 
......the boss wants the time worked represented in hours and tenths of hours not minutes. How can I take the time, seperate the hours...find out how many tenths of an hour worked and then add the hours and tenths together.

If you mean time worked represented in Hours with decimal places, you can use the expression:-
([EndTime]-[StartTime])*24

as [EndTime]-[StartTime] remains a date/time value and the unit of a date/time value is day and each day has 24 hours. If your version of Access has the Round() function, you can round it to 3 or 4 decimal places e.g.

Total Hours: Round(([EndTime]-[StartTime])*24,3)


However, if what you want are the number of Hours and the number of complete 10ths of Hour, you can use these two expressions:-

Hours: DateDiff("s", [StartTime], [EndTime])\3600

10thsHour: (DateDiff("s", [StartTime], [EndTime]) Mod 3600)\360


See the two queries in the attachment.
- Query1 illustrates the using of the above three expressions.
- Query2 shows how to sum the three expressions by ID.
.
 

Attachments

I ended up using this.

TotalTime: Round(Hour([ConEndTime]-[constarttime])+Minute([ConEndTime]-[constarttime])/60,2)
 
Looks like the issue is resolved. Thanks for posting back.
 
Originally Posted by JReichnan

I ended up using this.

TotalTime: Round(Hour([ConEndTime]-[constarttime])+Minute([ConEndTime]-[constarttime])/60,2)

Since you just want the total time to be displayed in Hours with decimal places,
why not simply use Jon K's first expression:
Round(([conEndTime]-[conStartTime])*24, 2) ?​

^
 
Last edited:
Thanks Emp...but with substituting numbers it just wouldnt seem to work. say end time = 2pm and start time = 1 pm then the equation would yeild 24 which would be worng. The idea is to take an end time of 1pm and a start time of 11:54 which would yeild a total time of 1hour 6 mins. The equation would then turn the answer to 1.1hours which can be added or subtracted correctly in an equation. Jeff
 
JReichnan said:
Thanks Emp...but with substituting numbers it just wouldnt seem to work. say end time = 2pm and start time = 1 pm then the equation would yeild 24 which would be worng. The idea is to take an end time of 1pm and a start time of 11:54 which would yeild a total time of 1hour 6 mins. The equation would then turn the answer to 1.1hours which can be added or subtracted correctly in an equation. Jeff
Jeff ...I don't see why you said Jon's expression wouldn't seem to work.

I created a table with the times that you mentioned
Code:
conStartTime	conEndTime
1:00:00 PM	2:00:00 PM
11:54:00 AM	1:00:00 PM

When I ran a query using his expression and yours, I got these results:
Code:
				TotalTime 	TotalTime
				using Jon's	using your
conStartTime	conEndTime	expression	expression
1:00:00 PM	2:00:00 PM		1		1
11:54:00 AM	1:00:00 PM	      1.1	      1.1

So when end time = 2pm and start time = 1 pm, his expression yielded 1, not 24 as you said it would.

Jon's simple expression of Round(([conEndTime]-[conStartTime])*24, 2) did return the correct results.

EMP
^
 
... with substituting numbers it just wouldnt seem to work. say end time = 2pm and start time = 1 pm then the equation would yeild 24 which would be worng.
When end time = 2pm and start time = 1 pm,

[end time] - [start time] would return 0.0416666666666667 (day)

0.0416666666666667 is equivalent to 1/24

So ([end time] - [start time])*24 returns 1 (hour). It would not return 24.
.
 

Users who are viewing this thread

Back
Top Bottom