View Full Version : Time Calculations or mis-caluculations in this case


BigDogTroy
02-12-2008, 08:19 AM
I have a query with 2 time fields, a start time, and an end time. I am subtracting the endtime from the starttime and I am getting funny numbers. Example: 12:12:04pm - 12:05:20pm and I am getting #Error. Where am I going wrong? Your help is greatly appreciated.:eek:

RuralGuy
02-12-2008, 08:43 AM
This link should help unless you do not have DateTime fields.
Calculate differences in time (http://www.mvps.org/access/datetime/date0004.htm)

BigDogTroy
02-12-2008, 08:58 AM
I am extracting the time from a Date/Time field in another query, using that query info, I am trying to calculate the difference between the 2 times to figure out how long the person was on the phone. Using the "Format([StartTime] -1 -[EndTime], "Short Time")" format, I am still getting an error. Is this because the fields I'm working with is a calculated field in another query?

RuralGuy
02-12-2008, 09:13 AM
You may want to avail yourself of the CDate() function.

DCrake
02-15-2008, 12:52 AM
Have you thought of using the DateDiff Function

Example:

Elapsed = DateDiff("n",#15/02/2008 08:45:00#,#15/02/2008 08:50:00#)

n = Minutes
s = Seconds

One thing you will have to take into consideration is the fact that what happens if the date crosses midnight. In the above example I have included the Date, however you can omit the date element to work on time values only.

Code Master::cool:http://www.icraftlimited.co.uk