Forum Discussion
PowerPaddy
9 years agoFrequent Visitor
DATEDIFF month interval not working as expected.
Hello again, I'm using the DateDiff function to work out after how many months a policy was cancelled but it's not giving me the expected results. Cancellation Month = DATEDIFF([POLICYSTARTDAT...
- 9 years ago
To get more accurate "MONTHDIFF", you can create a column like below:
Cancellation Month = ( 1 * ( [CANCELDATE] - [POLICYSTARTDATE] ) ) / DAY ( EOMONTH ( [CANCELDATE], 0 ) )Regards,
Greg_Deckler
Community Champion
9 years agoYour understanding is incorrect. DATEDIFF counts the "interval boundaries" crossed between the two dates. Therefore, going from Jan 31st to Feb 1st crosses the month interval boundary (new month).
PowerPaddy
9 years agoFrequent Visitor
Thank you.
IBM gives the description of the DATEDIFF function on their website...
"The result will be the integer portion of the number of months between the two dates, with any fractional component truncated."
I will have to count number the number of days instead as a workaround.
- v-sihou-msft9 years ago
Microsoft Employee
To get more accurate "MONTHDIFF", you can create a column like below:
Cancellation Month = ( 1 * ( [CANCELDATE] - [POLICYSTARTDATE] ) ) / DAY ( EOMONTH ( [CANCELDATE], 0 ) )Regards,
- Greg_Deckler9 years ago
Community Champion
IBM is not the authority on DAX:
This is the authority:
https://msdn.microsoft.com/en-us/library/dn802538.aspx