Microsoft Access - How do I write a query which calculates the number of minutes between two hour:min fields?

Asked By Bob on 17-Jul-12 04:53 PM
I have two time fields in a table in the HH:MM format. I want to write a query that calculates the time lapse/difference in minutes. In some cases, there is a cross over the line between 23:59 (11:59 p.m.) and 00:00 (12:00 a.m.) of the following day, i.e. one event occurs, say, at 23:05 and the other at 00:15.  How is this done? Thanks,

Bob
wally eye replied to Bob on 17-Jul-12 06:44 PM
A simple comparison:

Diff: Format(IIf([end]<[start],1,0)+[end]-[start],"hh:mm")

This won't allow for more than one day.
Bob replied to wally eye on 18-Jul-12 12:22 PM
Thanks. When I run the query it asks for a parameter. Since I have no idea of what that might be, I enter a blank, and I get no results (a blank column). How can I write the formula so it just does the calculation? Thanks, Bob
wally eye replied to Bob on 18-Jul-12 01:19 PM
replace the "start" and "end" with the field names from your tables...
Bob replied to wally eye on 18-Jul-12 01:35 PM
It goes without saying...or it should..that I understood your initial reply and substituted the fieldnames. I experimented with the formats [tablename].[fieldname] and just [fieldname], but with the same results. I also added 0s (00:00) where some data was missing from the table. Still no results. Thanks, Bob
wally eye replied to Bob on 18-Jul-12 05:50 PM
Can you post the pertinent table structure up?  It was working in my sample database.  I set up my table with Short Time on both fields.
Pat Hartman replied to Bob on 18-Jul-12 08:12 PM
When Access prompts for a parameter, it means that you have a typo somewhere.  Take the query apart piece by piece until you find it.
Bob replied to Pat Hartman on 19-Jul-12 10:29 AM
Thanks to both of you. I did find an error in the query, deleted it, and it now runs perfectly. Bob