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 difference in months from seperate month and year field

(0) ShareShare
ReportReport
Posted on by 53
Hi
I want to make a calculative field which capture the difference in months between two dates.
 
I have 4 separate fields namely Exp. Project Start month,  Exp. Project Start Year, Exp. Project End month, Exp. Project End Year.
 
//
 
My requirement is to create a new calculated field which capture difference in months based on above four fields.
For Ex. For above case calculated field should return 14 (For start month we consider 1st date of the month and for end month we consider last date of the month. Hence the result is 14 months).

Please help how to achieve this.  
  • Dengliang Li Profile Picture
    Microsoft Employee on at
    Calculate difference in months from seperate month and year field
    Hi,
     
    Has the issue been solved?
    Have there been any updates? Please feel free to ask me if you have any questions!
    If it has been resolved, can you mark the response as an answer?
     
  • Suggested answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Calculate difference in months from seperate month and year field
    Hi,
     
    Unfortunately, this cannot be implemented using the calculated column.
    You can use the Fx formula column to implement this.
    The formulas are as follows.
     
    The formula first determines whether Exp. Project End Year is greater than or equal to Exp. Project Start Year.
    The Switch function converts the two month field values to corresponding numbers.
    Use the Text function to convert the date difference to a number, and then use the Concatenate function to add custom text to the difference.
     
    If('Exp. Project End Year'>='Exp. Project Start Year',Concatenate(Text(('Exp. Project End Year'-'Exp. Project Start Year')*12-Switch('Exp. Project Start month',
        "Jan",1,
        "Feb",2,
        "Mar",3,
        "Apr",4,
        "May",5,
        "Jun",6,
        "Jul",7,
        "Aug",8,
        "Sep",9,
        "Oct",10,
        "Nov",11,
        "Dec",12)+Switch('Exp. Project End month',
        "Jan",1,
        "Feb",2,
        "Mar",3,
        "Apr",4,
        "May",5,
        "Jun",6,
        "Jul",7,
        "Aug",8,
        "Sep",9,
        "Oct",10,
        "Nov",11,
        "Dec",12)+1,"#")," months"))
     
    The final result is shown below.
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
     

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,758 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans