Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
AFra
Helper III
Helper III

calculate months between two dates without taking in account the day

Hi all, 

 

I would like to calculate the number of months in a list. For each element, I have a start date and an end date. I would like to count the number of months between the two dates, regardless of the day and including the starting and ending months. For example:

  • start date 31-01-2020
  • end date 10-02-2020
  • result: 2 months

any idea how to do that? 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @AFra 
Datedif function
When calculating intervals between months, Dax does not account for whether exactly 30/31 days pass between months.
Thus, its standard form will give you the difference you asked for.

 
MonthQTY = DATEDIFF('Table'[Start ],'Table'[End],MONTH)


As you added an extra month in your example, just add 1 at the end.

ExtraMonth = DATEDIFF('Table'[Start ],'Table'[End],MONTH)+1

Ritaf1983_0-1682737616364.png

Ritaf1983_2-1682737710464.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

1 REPLY 1
Ritaf1983
Super User
Super User

Hi @AFra 
Datedif function
When calculating intervals between months, Dax does not account for whether exactly 30/31 days pass between months.
Thus, its standard form will give you the difference you asked for.

 
MonthQTY = DATEDIFF('Table'[Start ],'Table'[End],MONTH)


As you added an extra month in your example, just add 1 at the end.

ExtraMonth = DATEDIFF('Table'[Start ],'Table'[End],MONTH)+1

Ritaf1983_0-1682737616364.png

Ritaf1983_2-1682737710464.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

Top Kudoed Authors