Comparing dates in Excel is achieved by using basic mathematical operators (like >, <, and =) or specific functions like DATEDIF and NETWORKDAYS. Because Excel stores dates as sequential serial numbers, you can subtract one date from another to find the number of days between them or use a logical formula to determine if one date occurs before or after another.

What You'll Need

  • Microsoft Excel (any modern version)
  • A dataset containing at least two columns of dates
  • Dates formatted as "Date" cells (not stored as plain text)

Step-by-Step

  1. Verify Date Formatting Before comparing, ensure your data is actually recognized as dates. Select your date columns, go to the Home tab, and check the Number format dropdown. It should say "Date." If the dates are aligned to the left of the cell, Excel likely sees them as text, and formulas will not work.
  2. Check if Two Dates are Identical To see if two dates are exactly the same, use a simple equals sign. In an empty cell, type: =A2=B2 (assuming your dates are in cells A2 and B2).
    • If the dates are the same, Excel returns TRUE.
    • If they differ, it returns FALSE.
  3. Determine Which Date is Earlier or Later Use logical operators to find overdue dates or future deadlines.
    • To find if A2 is after B2: Type =A2>B2. This returns TRUE if A2 is a more recent date.
    • To find if A2 is before B2: Type =A2<B2. This returns TRUE if A2 is an older date.
  4. Calculate the Difference in Days Since dates are numbers, the fastest way to find the gap between two dates is subtraction.
    • Type =B2-A2.
    • If the result looks like a date (e.g., 1/15/1900), change the cell format to General or Number via the Home tab. This will show the actual number of days between the two dates.
  5. Calculate Age or Tenure (Years, Months, Days) For more complex comparisons, such as calculating an exact age, use the DATEDIF function. Note that this function is "hidden" and will not appear in the autocomplete list, but it works in all versions.
    • For years: =DATEDIF(A2, B2, "y")
    • For months: =DATEDIF(A2, B2, "m")
    • For days: =DATEDIF(A2, B2, "d")
  6. Compare Dates to Today's Date To create a dynamic comparison that updates every time you open the file, use the TODAY() function.
    • To find days remaining until a deadline: =A2-TODAY()
    • To flag overdue items: =IF(A2<TODAY(), "Overdue", "On Time")
  7. Highlight Differences with Conditional Formatting If you want to visually flag dates that meet a certain criteria (e.g., all dates in the past):
    1. Select the range of dates.
    2. Go to Home > Conditional Formatting > New Rule.
    3. Select "Use a formula to determine which cells to format."
    4. Enter =A2<TODAY() (replace A2 with the first cell in your selection).
    5. Click Format, choose a fill color (like red), and click OK.

Common Mistakes

  • Text-Formatted Dates: The most common error is importing dates that look like dates but are stored as text. Formulas like =A2>B2 will not work correctly on text. Use the "Text to Columns" tool or the DATEVALUE function to convert them.
  • Wrong Cell Formatting: When subtracting dates, Excel often automatically formats the result cell as a "Date." This results in a weird date like "January 5, 1900" instead of the number "5." Always change the result cell to General or Number.
  • Incorrect Order in DATEDIF: The DATEDIF function requires the start date to be the first argument and the end date to be the second. If the start date is later than the end date, Excel will return a #NUM! error.

Tips

  • Working Days Only: If you need to compare dates but exclude weekends and holidays, use =NETWORKDAYS(A2, B2) instead of simple subtraction.
  • Absolute References: If you are comparing a whole column of dates against one single "Target Date" in cell G1, use an absolute reference: =A2>$G$1. The dollar signs prevent the reference to G1 from shifting as you drag the formula down.
  • Handling Blanks: If some cells are empty, your comparison might return a 0 or a weird number. Wrap your formula in an IF statement: =IF(OR(A2="", B2=""), "", A2-B2). This keeps the cell blank if either date is missing.

Troubleshooting

If your date comparisons are not working as expected, try these steps in order:

  1. Check for Hidden Spaces: Sometimes dates imported from other software have leading or trailing spaces. Use the =TRIM(A2) function in a helper column to clean the data.
  2. Test with a Simple Formula: Type =ISNUMBER(A2). If it returns FALSE, Excel does not recognize the cell as a date. You must convert the column to a Date format.
  3. Check Regional Settings: If you are using a date format like DD/MM/YYYY but your computer is set to MM/DD/YYYY, Excel may misinterpret the dates or treat them as text. Check your system region settings in the Control Panel.
  4. Verify Formula Syntax: Ensure you haven't missed a comma or a quotation mark in functions like DATEDIF.

Frequently Asked Questions

Why does my date subtraction result in a date instead of a number?

Excel tries to be helpful by applying the format of the source cells to the result cell. Since you subtracted dates, it assumes you want a date. Change the cell format to "General" or "Number" to see the count of days.

How do I compare dates in two different columns and highlight the matches?

Use Conditional Formatting with the formula =$A2=$B2. Apply this to your selected range, and Excel will highlight every row where the dates in column A and B are identical.

Can I compare dates that include timestamps (Date and Time)?

Yes, but be careful. If one cell is "2023-01-01" and another is "2023-01-01 10:00 AM," they are NOT equal. To compare only the date portion, use the INT function: =INT(A2)=INT(B2). This strips the time and compares only the date.

What is the best way to find the number of months between two dates?

The DATEDIF function is the most accurate. Use =DATEDIF(start_date, end_date, "m"). This calculates the number of complete months that have passed.

How do I find dates that fall within a specific range?

Use the AND function. For example, to see if a date in A2 is between January 1st and January 31st, use: =AND(A2>=DATE(2024,1,1), A2<=DATE(2024,1,31)).