How to Compare Dates in Excel (Easiest Way in 2024)
In this article, we will show you various formulas to compare dates in Excel. Simply follow the steps below.
Formula to Compare Dates in Excel
To compare two dates in Excel, you can use the methods: use the DATEDIF function, compare dates with IF function, or display custom messages based on date comparison. Simply follow the steps below.
Method 1: Use the DATEDIF Function
Use the DATEDIF function to calculate the difference between two dates in days, months, or years.
Calculate Difference in Days
In cell C1, type =DATEDIF(A1, B1, "D")
to find the difference in days.
Calculate Difference in Months
To find the difference in months between two dates, in cell E1, type =DATEDIF(A1, B1, "M")
. This will show how many full months are between the two dates.
Calculate Difference in Years
To find the difference in years between two dates, in cell E1, type =DATEDIF(A1, B1, "Y")
. This will show how many full years are between the two dates.
Method 2: Compare Dates with IF Function
Use the IF function to compare dates and display a specific result. For instance, to check if the date in A1 is earlier than the date in B1, type =IF(A1<B1, "A1 is earlier", "A1 is not earlier")
in cell C1.
Method 3: Display Custom Message Based on Date Comparison
Combine IF and DATEDIF to display custom messages. For example, to display a message if the dates are within one month, type =IF(DATEDIF(A1, B1, "M")<=1, "Dates are within one month", "Dates are more than one month apart")
in cell G1.
We hope you now have a better understanding of how to compare two dates in Excel. If you enjoyed this article, you might also like our article on how to make a box and whisker plot in Excel or our article on how to compare two columns in Excel to find differences.