Table of contents
TOC
Collapse the table of content
Expand the table of content

DATEDIFF Function (DAX)

Owen Duncan|Last Updated: 5/22/2018

Returns the count of interval boundaries crossed between two dates.

Syntax

DATEDIFF(<start_date>, <end_date>, <interval>)  

Parameters

TermDefinition
start_dateA scalar datetime value.
end_dateA scalar datetime value Return Value.
intervalThe interval to use when comparing dates. The value can be one of the following:

- SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR

Return Value

The count of interval boundaries crossed between two dates.

Remarks

An error is returned if start_date is larger than end_date.

Example

Date
2012-12-31 23:59:59
2013-01-01 00:00:00

The following all return 1:

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], second ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], minute ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], hour ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], day ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], week ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], month ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], quarter ) )  

DATEDIFF(MIN( Calendar[Date] ), MAX( Calendar[Date], year ) )  
© 2018 Microsoft