DATEDIFFDATEDIFF

Retorna a contagem de limites de intervalo cruzados entre duas datas.Returns the count of interval boundaries crossed between two dates.

SintaxeSyntax

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

ParâmetrosParameters

TermoTerm DefiniçãoDefinition
start_datestart_date Um valor de datetime escalar.A scalar datetime value.
end_dateend_date Um Valor retornado do valor datetime escalar.A scalar datetime value Return value.
intervalinterval O intervalo a ser usado ao comparar datas.The interval to use when comparing dates. O valor pode ser um dos seguintes:The value can be one of the following:

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

Valor retornadoReturn value

A contagem de limites de intervalo cruzados entre duas datas.The count of interval boundaries crossed between two dates.

ComentáriosRemarks

Um erro será retornado se start_date for maior que end_date.An error is returned if start_date is larger than end_date.

ExemploExample

DataDate
2012-12-31 23:59:592012-12-31 23:59:59
2013-01-01 00:00:002013-01-01 00:00:00

Todos os seguintes retornam 1: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 )