Skip to main content
DATE_DIFF

Calculates the difference in days, weeks, months, quarters, or years between two dates

Updated over 11 months ago

Description

The DATE_DIFF() function computes the time difference in days, weeks, months, quarters, or years between two provided dates (End_date and Start_date). This is useful for tracking durations, aging calculations, or date-based analytics.

Syntax

DATE_DIFF(End_date, Start_date, “day”/”week”/”month”/”quarter”/”year”)

Output

integer

Variables

  1. End_date: The ending date for the calculation.

  2. Start_date: The starting date for the calculation.

  3. "day"/"week"/"month"/"quarter"/"year": Specify the time unit (day, week, month, quarter, or year) for the calculation.

NOTE: Please note that the End_date and Start_date should both be in the same data type (e.g., date or datetime).

Example 1

DATE_DIFF(`End Date`, `Start Date`, "DAY")

Project

Start Date

End Date

DATE_DIFF

Project A

2023-09-05

2023-09-15

10

Project B

2023-08-25

2023-09-10

16

Project C

2023-09-01

2023-09-30

29

Example 2

DATE_DIFF(`End Date`, `Start Date`,"WEEK")

Project

Start Date

End Date

DATE_DIFF

Project A

2023-09-05

2023-09-15

1

Project B

2023-08-25

2023-09-10

2

Project C

2023-09-01

2023-09-30

4

Example 3

DATE_DIFF(`End Date`, `Start Date`,"MONTH")

Project

Start Date

End Date

DATE_DIFF

Project A

2023-09-05

2023-09-15

0

Project B

2023-08-25

2023-09-10

1

Project C

2023-09-01

2023-09-30

0

Did this answer your question?