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!

Calculating Time Difference 2

Status
Not open for further replies.

rb9999

Programmer
May 23, 2003
32
US
I browsed the forums and couldn't find this exact situation discussed so here goes.

I am trying to calculate the difference between two times that are formatted like this "830", "1110", "1430" etc.

I really don't have to worry about crossing the 24 hour mark or anything. I just need to calculate, for example, the difference between 1220 and 1310 is 50 minutes.

I searched the web and searched help and cannot figure this out.

Lets call the values TIME1 and TIME2, any ideea on a function that could calculate this? It would be good to just create a function that I can pass two variables and it returns the difference in minutes.

Any help appreciated.
 
rb999,

you can use DateDiff("n", DateTime1, DateTime2)

This will calculate the difference in minutes.

Hope this helps

Leigh Moore
LJM Analysis Ltd
 
I tried this. These are the results I get

Time1 Time2 Result
835 845 14400
1755 1807 74880
800 855 72000

I was thinking you could divide the result by 1440 and get the right answer. This works if an hour barrier hasn't passed. So it works on example one and three, but not on the second one.
 
What is the data type of the TIME1 and TIME2 fields? The answer to your problem is rather different of they are "Date/Time", "Numeric" or "text" fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top