30 Advanced Excel Tips for 2026

Excel Champs / Excel Formulas List / How to Compare Two Dates in Excel
By Puneet Gogia (Microsoft MVP)

How to Compare Two Dates in Excel

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

To compare two dates, use the operators directly: =A1=B1 returns TRUE if they’re the same day, =A1>B1 if the first is later, and =A1<B1 if it’s earlier. Excel stores dates as numbers, so comparison works the same as it does on any other number, and the display format doesn’t matter — 15-Jan-2026 and 01/15/2026 compare as equal.

For a readable answer instead of TRUE/FALSE, wrap it in IF: =IF(A1>B1,"Later","Not later"). To compare against today, use =IF(A1<TODAY(),"Overdue","On track").

Two things that catch people out. If your cells also carry a time, two entries on the same day won’t match — strip the time with INT: =INT(A1)=INT(B1).

And if a date is stored as text (left-aligned in the cell), comparisons give wrong results silently rather than erroring; convert it first with =DATEVALUE(A1).

There are some situations where you need to compare two dates with each other. But before you do, you need to understand how dates are stored in Excel.

When you enter a date in Excel, it doesn’t just see it as a date; it stores it as a number. For example, January 1, 1900, is stored as the number 1, and January 2, 1900, is the number 2. If you type in December 31, 2020, Excel sees it as 44196. To see that number, change the cell format to General.

Here’s one important part: if you want to compare two dates, they must be valid according to Excel’s date system.

You can compare dates using a simple and quick formula that returns TRUE or FALSE. You can also use the IF function to get a custom message in the result while comparing two dates. The following example shows two different dates in cells A1 and B1.

compare-two-dates

You can use the following steps:

  1. First, enter the “=” equal sign in cell C1.
  2. Now refer to cell A1, where you have the first date.
  3. Next, enter the “=” equal sign again.
  4. After that, refer to cell B1, where you have the second date.
  5. In the end, hit Enter.
=A1=B1

Even though you see dates in the cells you compare, Excel works with the numbers behind them. The formula returns TRUE if both dates are the same and FALSE if they’re not.

formula-to-compare-dates

Comparison Operators You Can Use to Compare Dates

To compare dates in Excel, you can use different comparison operators:

  • Equal to (A1=B1) – Checks if the date in one cell is the same as in another. If the values are equal, the condition is TRUE; otherwise, it is FALSE.
  • Not equal to (A1<>B1) – Checks if the date in one cell differs from the date in another. If the values are not equal, the condition is TRUE; otherwise, it is FALSE.
  • Greater than (A1>B1) – Checks if the date in one cell is larger than in another. If the first value is greater, the condition is TRUE; otherwise, it is FALSE.
  • Less than (A1<B1) – Checks if the date in one cell is smaller than in another. If the first value is less, the condition is true; otherwise, it is false.
  • Greater than or equal to (A1>=B1) – Checks if the date in one cell is larger than or equal to the date in another cell. If the first value is greater or equal, the condition is true; otherwise, it is false.
  • Less than or equal to (A1<=B1) – Checks if the date in one cell is smaller than or equal to the date in another cell. If the first value is less or equal, the condition is true; otherwise, it is false.

Compare IF a Date is Greater than Another Date

In the following example, we compare the first date with the second to check if the first date is greater than (later than) the second date.

compare-greater-date

In the formula, we used the greater than (>) operator:

=A1>B1

It returns TRUE when the date in A1 is later than the date in B1.

If somehow you have dates with different date formats, you can still compare them with each other; the only thing that you need to take care of is that each one is a valid date.

Compare a Date with Today’s Date

In the same way, if you want to compare a date with today’s date, you can use the TODAY function. We used the TODAY function in the following example and compared it to another date.

=A1>TODAY()

This formula returns TRUE if the date in A1 is in the future. Use < to check if it’s in the past, or = to check if it’s today. As TODAY updates every day, the result can change when you open the file the next day.

compare-date-with-today

Compare Two Dates using the IF Statement

You can also use IF to compare two dates in Excel to get a meaningful message about the comparison in the result cell. Below are a few examples to compare two dates using different comparison operators.

  • The first formula checks if the date in cell A1 is the same as in cell B1. If they are equal, it returns “Dates are equal”; otherwise, it returns “Dates are not equal.”
  • The second formula checks if the date in cell A1 is later than in cell B1. If A1 is later, it returns “A1 is later”; otherwise, it returns “A1 is not later.”
  • The third formula checks if the date in cell A1 is earlier than in cell B1. If A1 is earlier, it returns “A1 is earlier”; otherwise, it returns “A1 is not earlier.”
=IF(A1=B1,"Dates are equal","Dates are not equal")
=IF(A1>B1,"A1 is later","A1 is not later")
=IF(A1<B1,"A1 is earlier","A1 is not earlier")

Compare Dates Based on Years, Months, or Days

If you want to compare only the year, month, or day of two dates, then you need to write the formula differently.

  • The first formula checks if the year part of the date in cell A1 is the same as in cell B1. If the years are equal, it returns “Years are equal”; otherwise, it returns “Years are not equal.”
  • The second formula checks if the year of the date in cell A1 is greater than in cell B1. If the year of A1 is later, it returns “A1 year is later”; otherwise, it returns “A1 year is not later.”
  • The third formula checks if the year of the date in cell A1 is less than the year of the date in cell B1. If the year of A1 is earlier, it returns “A1 year is earlier”; otherwise, it returns “A1 year is not earlier.”
=IF(YEAR(A1)=YEAR(B1),"Years are equal","Years are not equal")
=IF(YEAR(A1)>YEAR(B1),"A1 year is later","A1 year is not later")
=IF(YEAR(A1)<YEAR(B1),"A1 year is earlier","A1 year is not earlier")

And in the same way, we have formulas to compare dates based on months and days:

  • The first formula checks if the month of the date in cell A1 is the same as in cell B1. If the months are equal, it returns “Months are equal”; otherwise, it returns “Months are not equal.”
  • The second formula checks if the month of the date in cell A1 is greater than in cell B1. If the month of A1 is later, it returns “A1 month is later”; otherwise, it returns “A1 month is not later.”
  • The third formula checks if the month of the date in cell A1 is less than in cell B1. If the month of A1 is earlier, it returns “A1 month is earlier”; otherwise, it returns “A1 month is not earlier.”
=IF(MONTH(A1)=MONTH(B1),"Months are equal","Months are not equal")
=IF(MONTH(A1)>MONTH(B1),"A1 month is later","A1 month is not later")
=IF(MONTH(A1)<MONTH(B1),"A1 month is earlier","A1 month is not earlier")

MONTH only looks at the month number, so March 2021 and March 2022 count as the same month. To check the month and the year together, compare both with TEXT:

=TEXT(A1,"yyyymm")=TEXT(B1,"yyyymm")

And here are the formulas for the day part of the dates:

  • The first formula checks if the day part of the date in cell A1 is the same as the day part of the date in cell B1. If the days are equal, it returns “Days are equal”; otherwise, it returns “Days are not equal.”
  • The second formula checks if the day of the date in cell A1 is greater than in cell B1. If the day of A1 is later, it returns “A1 day is later”; otherwise, it returns “A1 day is not later.”
  • The third formula checks if the day of the date in cell A1 is less than the day of the date in cell B1. If the day of A1 is earlier, it returns “A1 day is earlier”; otherwise, it returns “A1 day is not earlier.”
=IF(DAY(A1)=DAY(B1),"Days are equal","Days are not equal")
=IF(DAY(A1)>DAY(B1),"A1 day is later","A1 day is not later")
=IF(DAY(A1)<DAY(B1),"A1 day is earlier","A1 day is not earlier")

Compare Dates Where You Have Time Along with Dates

If you have two dates where you have time along with the dates, you can still compare them with all the formulas that you have learned above.

But the problem is that when you have the same date with different times, Excel treats the two values as different. To work around this, use the INT function, which removes the time part and keeps only the date:

=INT(A1)=INT(B1)

For 15-Mar-2022 10:00 and 15-Mar-2022 18:30, =A1=B1 returns FALSE, but this formula returns TRUE.

Frequently Asked Questions

Why does Excel say two same dates are not equal?

Either one of them has a time part (use INT, as shown above), or one of them is a date stored as text. Change the cell format to General: a real date shows a number, while a text date stays as it is.

How do I compare a date with a date typed in the formula?

Use the DATE function instead of typing the date as text. The following formula checks if the date in A1 is after 31-Dec-2022:

=A1>DATE(2022,12,31)

How do I find the number of days between the two dates?

Subtract the earlier date from the later one, and format the result cell as General to see the number of days:

=B1-A1
Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel

Leave a Comment