Comparing time w/o seconds

ghelfer

New Member
Joined
Jul 13, 2010
Messages
3
Hello, I need to compare diferents times without seconds and sum the respectives kilometers but both are formated with seconds, please see below:

time1......... km1.......time2........km2
03:15:45.......7.......03:15:55.......8
03:18:26.......7.......03:19:39.......9
03:20:33.......8.......03:21:42.......5

if time1=time2 then
km = km1+km2
else
km = km1
end if

Before the "if" I have a "for" that runs in the both columns (time1, km1, km2, time2)...

time1 and time2 formated in text are:1,13572916666667 and 1,13543981481481

Is there a function or special formula that rounds time??

Thanks in advance....
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This formula will round the time from cell A2 to the nearest minute
=ROUND(A2 / "00:01:00", 0) * "00:01:00"

Or this...
=ROUND(A2/TIME(0,1,0),0)*TIME(0,1,0)

Use something like this in VBA code...
Code:
Range("B2").Value = Round(Range("A2").Value / TimeValue("0:01:00"), 0) * TimeValue("0:01:00")
 
Upvote 0
Hi

A simple solution is to compare the text in the cell:

Code:
If Left(Range("A2").Text, 5) = Left(Range("C2").Text, 5) Then
 
Upvote 0
P. S. in my answer I assumed that when you say

... I need to compare diferents times without seconds ...

You mean you want to compare the times after rounding them down to the minute.

If what you want to know is if the difference between the 2 times is less than 1 minute you can use:

Code:
If Abs(Range("A2").Value - Range("C2").Value) <= TimeSerial(0, 1, 0) Then
 
Upvote 0

Forum statistics

Threads
1,215,048
Messages
6,122,862
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top