Forum Discussion
Victormar
Helper V
2 years agoWrong result using DATESDIFF
Hello community, I am facing a problem when calculating datediff from when a contract starts up until today, basically I want to know which year number are we in, but the results looks wrong, is it...
- 2 years ago
when you make datesdiff by year, it gets the difference between the year only not the whole date, so it takes that what's the different between 2023 to 2024,it's 1, because 23+1 = 24
Idrissshatila
Super User
2 years agoHello Victormar ,
you can specify the interval as you want in the datesdiff function.
examples:
( "Year", DATEDIFF ( StartDate, EndDate, YEAR ) ),
( "Quarter", DATEDIFF ( StartDate, EndDate, QUARTER ) ),
( "Month", DATEDIFF ( StartDate, EndDate, MONTH ) ),
( "Week", DATEDIFF ( StartDate, EndDate, WEEK ) ),
( "Day", DATEDIFF ( StartDate, EndDate, DAY )
check this https://learn.microsoft.com/en-us/dax/datediff-function-dax
Victormar
Helper V
2 years agothanks!