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!

math operations with time values

Status
Not open for further replies.

tranchemontaigne

Technical User
Apr 26, 2004
44
US
PROBLEM: I have a text box with a start time and a test box with a finish time value. I want to calculate the number of minitues that elapsed between these two values and display it in a 3rd text box.

FAILED APPROACH: My first thought was to make a click event that took the date/time value from one box and subtracted the date/time value from the second text box. This produced a fractional number that needed to be converted back into a date/time value using the cdate() function.

CONSIDERATION: This works, but is somewhat problematic if there is less than one hour between start and finish time. (date/time settings do not allow for a zero hour so the hour defaults to 12 (as it would do with midnight). (i.e. [3:00 PM] - [2:45 PM] = [12:15 AM])

GOAL: Ideally I would like this math operation ([3:00 PM] - [2:45 PM]) to produce the result of either [0:15] or [.25 hours]. I have no preference between either of these outputs.

Any thoughts on how to do this would be appreciated. I would gladly scrap the event driven approach if someone has a better idea.
 
Have you looked into using the DateDiff function, which works with both dates and times?

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
And what about something like this ?
Format(24 * ([finis time] - [start time]), "0.00")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top