Compare Two Dates in Excel & Google Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on February 6, 2023
Download Example Workbook

Download the example workbook

This tutorial will demonstrate how to compare dates in Excel and Google Sheets.

compare two dates main function

Date Serial Numbers

It’s important to understand how Excel stores dates and times.

Dates are stored as serial numbers; each whole number representing a unique date. 1 represents 1/1/1900 and each number after that represents the days following 1/1/1900.

Number Date

Times are stored as decimal values representing a time of a day.

Time Value

A serial number containing a decimal value represents a date and time:

DATE and Time Serial number

Comparing Two Dates

To compare dates, you can use the usual Excel operators:

Compare two dates

Are Dates Equal?

You can test if dates are equal using the equals (=) sign. (Note: of course this won’t work as desired if the dates contain time values as well. We discuss this more below).

Are Dates Equal

Is Date Greater Than Another Date?

Greater Than Another

Is Date Less Than or Equal to Another Date?

Date Less Than or Equal

Comparing Two Dates with Times

However, if the dates contain times then you might get unexpected results:

Two Dates with Times

Instead, to compare dates only you can use the TRUNC Function to remove the times when making the comparison:

=TRUNC(B3)=TRUNC(C3)

Two Dates with Times Trunc

Compare Today with a Date

You can use the TODAY Function to compare today’s date with another date:

Compare With Today

Date Compare & IF Function

In the above examples, we were simply returning TRUE or FALSE depending on the result of the comparison. Instead, we can add the comparisons to an IF Function.  This formula will test if an item is “overdue”, by comparing today’s date with a due date:

=IF(TODAY()>B3,"Overdue","")

IF

Date Differences

The above examples will tell you if one date is different than another date, but it won’t tell you the amount of difference.

Days Difference Between Dates

To calculate the number of days between dates simply subtract the dates:

Days Difference Between

Months or Years Difference Between Dates

To calculate the number of months or years between dates, you’ll need to use the DATEDIF Function:

=DATEDIF(B3,C3,D3)

Datedif

Comparing Dates in Google Sheets

All of the above examples work exactly the same in Google Sheets as in Excel.

Compare Two Dates Google Sheet

AI Formula Generator

Try for Free

Excel Practice Worksheet

practice excel worksheet

Practice Excel functions and formulas with our 100% free practice worksheets!

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!

Free Download

Return to Excel Formulas List