DATEDIFF DAX Function (Date and Time)

Returns the number of units (unit specified in Interval) between the input two dates.


DATEDIFF ( <Date1>, <Date2>, <Interval> )
Parameter Attributes Description

A date in datetime format that represents the start date.


A date in datetime format that represents the end date.


The unit that will be used to calculate, between the two dates. It can be SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.

Return values

Scalar A single integer value.

The count of interval boundaries crossed between two dates.


The result is positive if Date2 is larger than Date1.
The result is negative if Date1 is larger than Date2.

Previous versions of the DAX engine (earlier than 2018) could provide an error if Date1 is larger than Date2.


--  DATEDIFF computes the delta between two dates, using different units of measure
--  YEAFRAC returns the delta as a fraction (in years) 
VAR StartDate =  DATE ( 2011, 01, 01 )
VAR EndDate =    DATE ( 2012, 12, 15 )
        ( "DATEDIFF Year",     DATEDIFF ( StartDate, EndDate, YEAR ) ),
        ( "DATEDIFF Quarter",  DATEDIFF ( StartDate, EndDate, QUARTER ) ),
        ( "DATEDIFF Month",    DATEDIFF ( StartDate, EndDate, MONTH ) ),
        ( "DATEDIFF Day",      DATEDIFF ( StartDate, EndDate, DAY ) ),
        ( "Subtraction-1",     INT ( EndDate - StartDate ) ),
        ( "Subtraction-2",     CONVERT ( EndDate - StartDate, INTEGER ) ),
        ( "YEARFRAC",          YEARFRAC ( StartDate, EndDate ) )
Value1 Value2
DATEDIFF Year 1.00
DATEDIFF Quarter 7.00
DATEDIFF Month 23.00
DATEDIFF Day 714.00
Subtraction-1 714.00
Subtraction-2 714.00

Last update: Jul 12, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Ed Hansberry

Microsoft documentation:

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.


Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.


This function is deprecated. Jump to the Alternatives section to see the function to use.


A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.


This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.


Want to improve the content of DATEDIFF? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.