DATE_DIFF

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

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")

  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.

Example

Table

Project
Start Date
End Date

Project A

2023-09-05

2023-09-15

Project B

2023-08-25

2023-09-10

Project C

2023-09-01

2023-09-30

Function

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

Results

DATEDIFF (integer)

10

16

29

Last updated