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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors