Hey guys! I have created an Access 2010 database. On one of the tables, there are fields [Start Time], [End Time] and [Total Time]. The user will input the start and end times but and the total time will be the difference between the two. I cannot figure out how to go about this. Any help or direction would be greatly appreciated!!

Recommended Answers

All 4 Replies

use the datediff function, inspite of its name it handles times as well as dates.

Thanks for you input Chris! I have tried to implement the DateDiff function but have ran into a snag. Below is how I am using it in a query.

Total Time: DateDiff("Short Time",[Work Start Time],[Work End Time])

It is returning "#Func!". Do you have any idea what could be causing this?

datediff returns a number, ie number of days, number of hours, number seconds depending on the first parameter. so if you want the number of hours between the two the call looks like

noHours = datediff("h",[Work Start Time],[Work End Time])

or in SQL

noHours:datediff("h",[Work Start Time],[Work End Time])

That worked! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.