Forum Discussion
Wrong result using DATESDIFF
- 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
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
Got it, thanks. I guess then the best solution is to do the difference in days and divide by 365? My idea is to calculate a natural year from the start date.
- Idrissshatila2 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
- Victormar2 years agoHelper V
thanks!