Power Query has a built-in Duration.Days function. But what about Duration.Months?
Why don’t we create a custom function for that?
(Date1 as date , Date2 as date) => let Source = List.Generate( () => [x = 1, y = Date.AddMonths(Date1,x)], each [y] <= Date2, each [x = [x] + 1, y = Date.AddMonths(Date1,x)], each [y] ), Months = List.Count(Source) in Months
Note: Date1 should be earlier than Date2.
Leave a Reply