web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to get the amount of months between 2 dates?

(0) ShareShare
ReportReport
Posted on by 450

Hi,

I know that you can get the amount of days between 2 dates by declaring an integer variable and simply do:

IntVar := DateRecent - DatePast;

Now i was wondering if there also is a way to do this in a way for monts instead of having to calculate with the days since there are months with 28, 30 and 31 dates.

Thanks in advance

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    You can use the Date table and filter accordingly.

    Maybe something like:

    IF (FromDate <> 0D) and (ToDate > FromDate) THEN BEGIN

       Date.SETRANGE("Period Type",Date."Period Type"::Month);

       Date.SETRANGE("Period Start",FromDate,ToDate);

       Months := Date.COUNT;

    END ELSE

        Months := 0;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 626 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 425 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 384 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans