DATEDIFF DAX Function (Date and Time)

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

Syntax

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

A date in datetime format that represents the start date.

Date2

A date in datetime format that represents the end date.

Interval

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.

Remarks

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.

Last update: Dec 14, 2018   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Jes Hansen

MSDN documentation: https://msdn.microsoft.com/en-us/query-bi/dax/datediff-function-dax

DAX Conventions
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.

Iterator

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.

Deprecated

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

Deprecated

This parameter is deprecated and its use is not recommended.

Contribute

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.