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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Calculate date difference into Month and Days

(0) ShareShare
ReportReport
Posted on by 1,235

Hi,

I would like to display 2 dates differences into month and days, e.g. 2 month 15 days. It seem standard calculated field is unable to achieve this, as the diffindays is calculate the total day in difference between the 2 dates.

In excel, we can use DATEDIF(A1,B1,"M") & "month ," &DATEDIF(A1,B1,"MD") & "days" it would return the desire result. How to achieve this ?

Thanks.

Regards,
Teh

I have the same question (0)
  • Suggested answer
    Emily Zhang Profile Picture
    on at

    I guess there's no oob function to achieve this. But you can write your own plugin.

    1. Register the plugin on record creation and update.

    2. Retrieve these 2 datetime attributes in plugin.

    3. Define 2 DateTime variable in the plugin, set datetime equals to attributes datetime.

    4. Compare month, days difference referring below document.

    docs.microsoft.com/.../system.datetime.month

    5. Pass the comparing difference back to CRM.

    But there's one issue with displaying 2 dates differences into month and days. For example: date1 is Jan 15th, date2 is March 3. If we compare date difference  into month and days, it will be come 2 month -12 days.

    If  you don't want negative number, then you need to make assumption, say every month is 30 days.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans