Forum Discussion
jshutters
7 years agoResolver I
Calculate 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
5 years agoAdvocate I
One 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]))
- dmatliak4 years agoFrequent Visitor
Hello is it possible to calculate number of days using date that I specify. I need to calculate number of day between August 31, 2021 and some Due date I have in data. When I use this formula Duration.Days(Date.From(2021-08-31) - Date.From([DEB_DAT])), it returns strange result.
Thanks for help