Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Calculate difference in months from seperate month and year field

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
    Dengliang Li 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
    Dengliang Li 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans