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

Find time difference

Status
Not open for further replies.

ddmtn546

Technical User
Dec 20, 2000
38
US
How would one find the difference in two time fields formatted in military time within a query? Example: StartTime-StopTime. Wheresas StartTime was 17:00 & StopTime was 19:00.
 
On the field line of a query try
MyTime:StopTime-StartTime

Depending on whether you have to account for different days, it may be all you need.

Paul
 
PaulBricker's solution will produce an answer in days and fractions of a day. If you want it in (for example) minutes, then
Code:
myTime: DateDiff ("n", StartTime, StopTime )
 
Actually, if both fields are formatted Short Time, values like
19:25 - 17:35
returns 1:50
without any addtional formatting.

Paul

 
Good point Paul. I guess I mentally relegate formatting to being a reporting issue and don't think of it's effect on computational results.

Probably the result of a programming rather than DBMS background.
 
Even within Access, it doesn't follow a clear pattern. It never seems the same twice when it comes to getting the format correct.[pc]

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top