Google Sheets Function: DATEDIF

The DATEDIF function calculates the number of days, months, or years between two dates.

Usage:

=DATEDIF(start_date, end_date, unit)


Number of days between 2 dates

To get the number of days between "12/15/2023" and "2/26/2024", enter these dates into the DATEDIF function along with the unit "D" to return the number of days:

=DATEDIF("12/15/2023","2/26/2024","D")
google sheets function datedif

If the dates are in cells, enter:

=DATEDIF(B1,B2,"D")
google sheets function datedif days

Note that in this case, you could also simply enter:

=B2-B1
google sheets number days between 2 dates datedif

Number of complete months between 2 dates

To get the number of complete months between 2 dates, enter the unit "M":

=DATEDIF(B1,B2,"M")
google sheets number months between 2 dates datedif

Number of complete years between 2 dates

To get the number of complete years between 2 dates, enter the unit "Y":

=DATEDIF(B1,B2,"Y")
google sheets number years between 2 dates datedif