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!

Subtraction of Two Times (hh:nn:ss - hh:nn:ss) 2

Status
Not open for further replies.

jvet4

Technical User
Jul 24, 2000
54
US
I am trying to develop a query that will subtract 2 times, both with the format hh:ss:nn and display the time in the same format (or if possible nn:ss). Using the subtraction operator ( - ) the answer I get is a very small decimal number (i.e. .006....).&nbsp;&nbsp;I tried to use the DATEDIFF function and was able to get the answer, but I had to display the answer in two different fields (Min and Sec), which is not very helpful.&nbsp;&nbsp;<br><br>Any help would be greatly appreciated.<br><br>Thanks, Jason
 
The date-time datatype is represented internally as a double precesion floatpoint number which is days since some fixed point in time.&nbsp;&nbsp;Its just given a type of date-tims so the system will know how to display it.<br><br>When you subtracted, you got the right answer, but the date-times were converted (without changing the bits in the internal represntation) to floating point to do the subtraction and then the result defaulted to floating point.<br><br>If you apply the Hour, and Minute functions to the difference you should get the values you require.
 
How are these functions applied?&nbsp;&nbsp;When I apply them I do get a number but it is not the correct value.&nbsp;&nbsp;I can't seem to find anyplace that tells the syntax of these functions.<br><br>Thanks for the help harryrich!<br><br>Jason
 
How about DateDiff(your min part) & &quot;:&quot; & DateDiff(your sec part) ?<br>Alternatively, Left(len(CDate(date1-date2))-5)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top