DATEDIFF

Calculates the difference between two specified dates in the given interval. If date2 is before date1, then the result will be negative.

Syntax

=DATEDIFF(interval, date1, date2)

Arguments

ArgumentTypeDescription
intervalStringThe type of interval to find the difference of
Valid intervals are:
- YEARS
- YEAR
- QUARTERS
- QUARTER
- MONTHS
- MONTH
- WEEKS
- WEEK
- DAYS
- DAY
- HOURS
- HOUR
- MINUTES
- MINUTE
- SECONDS
- SECOND
- MILLISECONDS
- MILLISECOND
date1DateThe starting date
date2DateThe ending date

Examples

=DATEDIFF("YEARS", DATE(2019), DATE(2020))1
Gets the number of years from Jan 1, 2019 12:00 AM to Jan 1, 2020 12:00 AM

=DATEDIFF("YEARS", DATE(2021), DATE(2019))-2
Gets the number of years from Jan 1, 2021 12:00 AM to Jan 1, 2019 12:00 AM

=DATEDIFF("MINUTES", DATE(2020, 1, 2, 3), DATE(2020, 2, 3, 4))46140
Gets the number of minutes from Jan 2, 2020 3:00 AM to Feb 3, 2020 4:00 AM