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

Calculating Time for Billing

Status
Not open for further replies.

eileen1309

Programmer
Dec 6, 2004
129
0
0
US
I've Searched the forum and found a few threads and tried a few of the suggestions but can't seem to get them to work. This is what I need to do..

I have two fields startdate and enddate both of which are set to a general date including time HH:MM:SS AM or PM


for instance
StartDate 10/05/2005 11:25:00 AM
EndDate 10/05/2005 12:45:00 PM
Total Hrs Worked = 1.20 hrs.

Any help would greatly be appreciated.

Eileen

There is light at the end of the tunnel!
 
A starting point:
Val(Format(EndDate-StartDate, "h.nn"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks but it still is not correct .. if I calculate the number of minutes between each date and divide by 60 I should be left with the hours and a fractional hour?

Here's What I have
10/05/2005 11:25:00 am
10/05/2005 06:00:00 pm

However, y = 6.5833333333
based on the above fields my total hrs worked should equal 5.25 hrs.

Function NoHours()
On Error GoTo noHourserr
Dim y As Double
'Dim z As Variant

y = DateDiff("n", Forms![UfrmTaskactions]![StartDate], Forms![UfrmTaskactions]![EndDate]) / 60


NoHoursExit:
Exit Function
noHourserr:
MsgBox Err.Number & " " & Err.Description
Resume NoHoursExit

End Function

Eileen

There is light at the end of the tunnel!
 
StartDate=#10/05/2005 11:25:00 AM#
EndDate=#10/05/2005 06:00:00 PM#
my total hrs worked should equal 5.25 hrs. ????
? Format(EndDate-StartDate, "h.nn")
6.35 (6 hrs 35 min)
? (EndDate-StartDate)*24
6.58333333331393 (6 hrs + fractional part)
 
Did you ever have one of those days? Thanks the answer I had was right all along.

Eileen

There is light at the end of the tunnel!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top