To compare two dates in Excel, enter this formula in a result cell: =IF(A2<B2,"A is earlier",IF(A2>B2,"A is later","Same date")), assuming the dates are in A2 and B2. It tells you which date comes first or whether they match. You can also subtract the dates to find the number of days between them, or use conditional formatting to highlight dates visually. The examples below are for Microsoft Excel for Microsoft 365 on Windows.
What You’ll Need
- A workbook with two cells containing dates, or a start date, end date, and date to check.
- Dates stored as Excel date values rather than unconverted text. You can usually enter a date directly into a cell and format it as a date.
- An empty column or cell for formula results if you want a written comparison or day count. You do not need an add-in.
For the examples, A2 holds the first date and B2 the second. Use actual dates in your sheet; for clarity, the examples refer to April 10 and April 15, 2026. A cell’s displayed date format can look different from its underlying value, so check that Excel recognizes the entries as dates before comparing them.
Step-by-Step
- Enter and check the dates. Put the first date in A2 and the second in B2. For example, enter April 10, 2026 in A2 and April 15, 2026 in B2. Select each cell and choose Home > Number Format dropdown > Short Date if you want a consistent display. The date may appear as 4/10/2026 or 10-Apr-2026 depending on your regional settings; either display is fine if Excel recognizes the value as a date. If a date is left-aligned and changing its number format has no effect, it may be text; see Troubleshooting.
- Compare which date comes first. With the first date in A2 and the second in B2, enter this formula in C2:
=IF(A2<B2,"A is earlier",IF(A2>B2,"A is later","Same date")). For April 10 in A2 and April 15 in B2, C2 returns “A is earlier.” The less-than and greater-than tests compare the underlying date values, not the way they are displayed. Copy the formula down if each row contains a separate pair of dates; Excel adjusts the row references automatically. If your columns have different names, change the references to the cells you are comparing. - Find the number of days between the dates. With A2 as the first date and B2 as the second date, enter
=B2-A2in C2. For April 10 and April 15, the result is 5 days because the later date is five days after the earlier one. If you want a nonnegative interval regardless of which date is earlier, use=ABS(B2-A2)with the same layout; this example also returns 5. Format the result cell as General or Number if it displays as a date. Subtraction gives elapsed days and does not count both endpoints as separate days. - Choose whether to count both endpoints. For a count that includes the start and end dates, use
=B2-A2+1, assuming A2 is the start and B2 is the end date. April 10 through April 15, counting both dates, is 6 calendar days. This is useful for inclusive schedules or date ranges, but it is not the same as elapsed time. If the dates might be entered in reverse order and you still want an inclusive count, use=ABS(B2-A2)+1with A2 and B2 holding the two dates. - Check whether a date falls within a range. Suppose A2 contains the range start, B2 the range end, and C2 the date you want to check. Enter
=AND(C2>=A2,C2<=B2)in D2. If A2 is April 10, B2 is April 15, and C2 is April 12, the result is TRUE. The formula treats the start and end as included. It returns FALSE for a date before April 10 or after April 15. If your range boundaries should not count as included, change the greater-than-or-equal and less-than-or-equal comparisons to strict comparisons. - Highlight earlier or later dates with conditional formatting. To compare the dates in columns A and B row by row, select A2:A100, then choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. With A2:A100 selected and the comparison dates in B2:B100, enter
=A2<B2to highlight the A date when it is earlier than the matching B date. Choose a format and select OK. Create another rule using=A2>B2for later dates, or=A2=B2for equal dates. Keep the row number relative so the rule compares each row with its partner. In Excel for Mac, the same formula logic applies, though the rule dialog may be arranged differently. Excel for the web supports common conditional-formatting rules, but its controls may be laid out differently. - Fill the comparison through your data. If your list has many date pairs, enter the formula in the first result row and drag the fill handle, the small square at the bottom-right corner of the selected cell, down the column. Alternatively, copy the result cell and paste it into the remaining rows. Check a few rows near the bottom to confirm the references shifted as intended and that blank rows are not producing misleading results.
Common Mistakes
Comparing text instead of dates: Dates imported from another file may be text, even if they look like dates. A formula can then give an unexpected result or fail to compare them chronologically. Changing the number format alone changes appearance; it does not necessarily convert text to a date value. Check the cell alignment and try a simple subtraction between the two entries. If subtraction returns an error, inspect the imported values and convert them before relying on the comparison.
Reversing the subtraction: =B2-A2 is positive when B2 is later than A2, but negative when B2 is earlier. That is mathematically correct, not an error. Use =ABS(B2-A2) if you need the distance without regard to order, or keep the signed result when direction matters.
Confusing elapsed days with inclusive days: Subtracting April 10 from April 15 returns 5, not 6. The first result measures the gap between dates; adding 1 counts each date in the range. Decide which meaning suits the task before using the result in a schedule or report.
Overlooking time values: Excel can store a time as part of a date. Two cells may display the same calendar date but compare as unequal if one contains a different time. For example, midnight and noon on the same day are different values. If you care only about calendar dates, remove the time component or use the calendar-day comparison in Tips.
Tips
Use labels such as “First date,” “Second date,” “Earlier/later,” and “Days apart” in the header row. This makes it easier to tell whether a positive number means the second date is later or simply represents an absolute interval. If you compare many rows, keep the date columns in a consistent order and store the result formula beside them.
To compare calendar days while ignoring any times in A2 and B2, use this formula with those two cells holding date-and-time values: =IF(INT(A2)<INT(B2),"A is earlier",IF(INT(A2)>INT(B2),"A is later","Same calendar day")). If both values are on April 10, 2026, but their times differ, it returns “Same calendar day.” INT removes the fractional time portion for the comparison. Use this only when the time of day is irrelevant; otherwise, compare the full values.
For recurring reports, convert your data range into an Excel table with Insert > Table. A formula entered in a table column is generally filled into the other rows automatically, and the column headers help clarify the inputs. Review the result after adding new rows, especially if some records have missing dates. A blank is not a meaningful date, and formulas may return results that need separate handling.
Excel for Mac uses the same basic comparison operators and formulas. The ribbon labels are usually similar, but dialog placement can vary by version. In Excel for the web, formulas such as IF, AND, and ABS work as shown; use the available Home ribbon controls if you need to set the number format or conditional formatting.
Troubleshooting
The formula displays as text or does not calculate. Check whether the result cell is formatted as Text. Change it to General, select the formula cell, press F2, then press Enter to make Excel evaluate the entry again. Also confirm that the formula begins with an equals sign and that there is no apostrophe before it.
A date looks right but the comparison is wrong. Confirm that both cells contain actual date values and use the same intended date order. A value such as 04/05/2026 can mean April 5 or May 4 depending on regional settings. Select each cell and inspect the formula bar, or temporarily format it as a long date to see how Excel has interpreted it. For imported text, use Data > Text to Columns and specify the correct date order when converting, or re-enter the dates using a format Excel recognizes in your region.
The day difference appears as another date. The result cell may be using a date format. Select it and choose Home > Number Format dropdown > General or Number. If the calculation produces a decimal, one or both inputs probably include a time. That decimal represents part of a day; format it as Number to see the value, or use a calendar-day comparison if the time should not matter.
Conditional formatting highlights the wrong rows. Check that the selected range starts on the same row referenced in the rule. For A2:A100, use A2 and B2 in the formula, not A1 and B1. Also confirm that you created the rule for the intended range and did not lock a row or column with dollar signs unintentionally. Open Home > Conditional Formatting > Manage Rules to review the rule and its Applies to range.
A range check returns FALSE for an expected date. Verify that the start date is not later than the end date and that all three cells are real dates. The example includes both boundaries; a date exactly equal to a boundary should return TRUE. If you instead used strict comparison signs, boundary dates will return FALSE.
Frequently Asked Questions
How do I tell whether two dates are equal? If the dates are in A2 and B2, enter =A2=B2 in another cell. It returns TRUE when their underlying values match and FALSE otherwise. If times are present, two entries on the same calendar day may not be equal as full date-and-time values.
How do I compare dates without showing a text message? Use a direct comparison such as =A2<B2, with A2 and B2 holding the dates. The result is TRUE if A2 is earlier and FALSE if it is not. Use =A2>B2 to test whether A2 is later.
Can Excel calculate the number of months or years between dates? It can, but “months between” can mean completed months, calendar-month boundaries, or an approximate number. Choose a definition that fits your task before selecting a calculation. For a straightforward day interval, subtract the dates; do not treat a day count divided by 30 as an exact month count.
Why does the same date comparison work on one computer but not another? Regional date settings can affect how typed or imported text is interpreted. Enter dates as recognized date values, check ambiguous entries, and avoid assuming that a slash-separated date has the same month/day order on every computer.
Can I compare a date with today? Yes. If A2 contains a date, enter =IF(A2<TODAY(),"Past",IF(A2>TODAY(),"Future","Today")) in another cell. TODAY returns the current date and updates when Excel recalculates. This checks the calendar date, not the current time.
Related
- American Date Format in Excel: How to Set MM/DD/YYYY
- Change Border Colour in Excel: A Step-by-Step Guide
- How to Center Text in Excel Using Keyboard Shortcuts
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Date Difference in Minutes in Excel: Formulas That WorkIf A2 contains a start date and time and B2 contains an end date and time, enter =(B2-A2)*1440…
- Excel Insert Image from URL: Formula, Steps, and FixesTo insert an image from a URL in Microsoft Excel for Microsoft 365, put the direct image address…
- Excel Time Card Formula: Track Hours and OvertimeFor a basic Excel time card, enter a start time in B2, an end time in C2, and…
- Excel Scenario Manager Tutorial: Compare What-If PlansTo use Excel Scenario Manager, build a worksheet model, then select Data > What-If Analysis > Scenario Manager…
- Excel MIN IF: Find the Smallest Value That Meets a TestTo find the smallest value in Excel that meets a condition, use MINIFS in Microsoft 365: with regions…
- How to Filter in Excel Using Keyboard Shortcuts and MenusTo filter a list in Excel for Microsoft 365 on Windows, select a cell in the data, press…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.