Forum Discussion
jshutters
Resolver I
7 years agoCalculate difference between two dates power query
How do I calculate the difference between two dates in Power Query M code (not DAX)? I'm looking for the number of days.
- 7 years ago
Hi jshutters
you need to use the duration functions: https://docs.microsoft.com/en-us/powerquery-m/duration-days
=each Duration.Days([Date1] - [Date2])
rfratto
Advocate I
5 years agoOne note: I kept receiving errors on the [Date1] - [Date2] until I explicitly converted my date values to a date using Date.From(): e.g. (for an aging calculation)
= Duration.Days(Date.From(DateTime.LocalNow()) - Date.From([Due_Date]))