DATEDIFF DAX Function in Power BI

The DATEDIFF DAX function in Power BI returns the number of interval boundaries between two dates.

DAX Syntax DATEDIFF(start_date, end_date, interval)

The function has the following parameters:

We can use the following keywords for interval:

IntervalDescription
SECONDDifference in seconds
MINUTEDifference in minutes
HOURDifference in hours
DAYDifference in days
WEEKDifference in weeks
MONTHDifference in months
QUARTERDifference in quarters
YEARDifference in years

Example: Calculate the Difference in Year.

DAX

DATEDIFF Measure = 
    DATEDIFF(
        DATE(2022, 4, 12), 
        DATE(2025, 6, 25), 
        YEAR
    )

The output of the above code is 3.

Example: Calculate the Difference in Quarter.

DAX

DATEDIFF Measure = 
    DATEDIFF(
        DATE(2022, 4, 12), 
        DATE(2025, 6, 25), 
        QUARTER
    )

The output of the above code is 12.

Example: Calculate the Difference in Months.

DAX

DATEDIFF Measure = 
    DATEDIFF(
        DATE(2022, 4, 12), 
        DATE(2025, 6, 25), 
        MONTHS
    )

The output of the above code is 38.

Note: • If end_date is earlier than start_date, result will be negative.
• Works with columns and measures.

Example: Calculate the Difference in Months, this time the result is -38.

DAX

DATEDIFF Measure = 
    DATEDIFF(
        DATE(2025, 6, 25), 
        DATE(2022, 4, 12), 
        MONTHS
    )

The output of the above code is -38.