Comparing time with different formats

CaptainGravyBum

Board Regular
Joined
Dec 1, 2023
Messages
94
Office Version
  1. 365
Platform
  1. Windows
Hello,
I think I'm going to answer my own question with this one, but there's probably an easy fix.
On the sheet attached, I need to check if the time in column B is less (earlier) than column A. It isn't working correctly and both columns are formatted as time, but I think column B has the date included in the data and I don't know how to either strip that out or add a date into the information in column A so it can do a correct comparison.
I do have the date relevant to column A in my main sheet, if it's just a case of combining the two columns.

Time.xlsx
ABC
112:00:0012:54:00TRUE
Sheet1
Cell Formulas
RangeFormula
C1C1=B1<A1
 
if you have a date
then in column B

(B1-INT(B1))<a1

date is a number and time is the decimal
so
B1-INT(B1)
removes the number part and just leaves the decimal
 
Upvote 0
if you have a date
then in column B

(B1-INT(B1))<a1

date is a number and time is the decimal
so
B1-INT(B1)
removes the number part and just leaves the decimal
Hi @etaf ,
Thanks for the reply, still isn't working, I think now it's because the time in A isn't converted to decimal, if I change the formatting to general A is 12:00:00 and B shows decimal 46501.54.
 
Upvote 0
yep its text
try clicking on column A
DATA
Text to columns
and just do next , next etc
se eif that now changes from text to real date -
 
Upvote 0
yep its text
try clicking on column A
DATA
Text to columns
and just do next , next etc
se eif that now changes from text to real date -
That works! My only issue is that my original data is fed from other sheets, is there a way to ensure it only returns the correct value from a vlookup?
 
Upvote 0
one way is to convert the text to real dates on the other sheets using text to columns
OR
=Timevalue( your vlookup formula)
may work
 
Upvote 0
FYI I managed to find a solution which involved stripping the time value only from one of the columns, because it had both date and time.
 
Upvote 0
Solution

Forum statistics

Threads
1,226,860
Messages
6,193,398
Members
453,794
Latest member
slilesy

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