Forum Discussion
Victormar
2 years agoHelper V
Wrong 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
2 years agoSuper User
Hello 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
2 years agoHelper V
thanks!