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

Finding time differences in access

Status
Not open for further replies.

ccs2

Instructor
Oct 8, 2003
37
GB
I want to use the DateDiff function to work out the time interval between a start time (e.g.10am) and an end time (e.g. 10.35) in a race.
Can anyone help?
 
You can use "n" to calculate time difference in minutes when using DateDiff function. Example is shown below

Public Function calculate_time_difference()
starttime = #10:00:00 AM#
endtime = #10:35:00 AM#
MsgBox starttime & Chr(13) & endtime & Chr(13) & DateDiff("n", starttime, endtime)
End Function
 
You may also consider this:
MsgBox Format(endtime - starttime, "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
 
I seem to have cracked this by setting up a SwimTotal field in the Selection table with a Data Type, Number/Long Integer. Then I set up an Update query as follows:

Field: SwimTotal
Table: tblSlection
Update to: DateDiff("s",[SwimStart],[SwimEnd])

This calculates the time in seconds (s). You will then have to divide this by 60 in an expression which you can put in a query if you wish, or on the form or in a report later (maybe all three). In a Triathlon you will need to do this for each race and then use an expression to add the three totals together in an Overall total field. Looks like fun!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top