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

Date diff in a Query

Status
Not open for further replies.

lakers8175

IS-IT--Management
Sep 18, 2001
67
US
I have two fields that I would like to find out the difference in minutes. Both fields are text. Is there a way to format the text to time and get the difference.

Time1 Time2
0255 0300

I would like the result to be 5. Because they are text fields I am having an issue.
 
You need to convert to DateTime and then take the difference
Code:
DateDiff("n",
    TimeSerial(Val(left(Time1,2)), Val(Right(Time1,2)),0),
    TimeSerial(Val(left(Time2,2)), Val(Right(Time2,2)),0))
 
Elapsed: 60*Left(Time2,2)+Right(Time2,2)-60*Left(Time1,2)-Right(Time1,2)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks!! Golom that did the trick. PHV thanks for the second option.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top