DATEDIFF Function (DAX)

 
System_CAPS_ICON_note.jpg Note


This function is included in SQL Server 2016 Analysis Services (SSAS), Microsoft Power Pivot in Excel 2016 Preview editions, and Microsoft Power BI Designer Preview only. Information provided here is subject to change.

Returns the count of interval boundaries crossed between two dates.

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

The count of interval boundaries crossed between two dates.

An error is returned if start_date is larger than end_date.

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

Community Additions

ADD
Show: