Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Increment date by x months using AddMonths not calculating correctly

Posted on by 507

Incrementing date field by months based on a user input field(#of months to increment)

1.LastScheduledDate(a simple date only field)

2. Increment field(whole number).

3. Calculated Field "NextDate" formula is: Set NextDate to AddMonths(Increment;LastScheduledDate)

4. I have a workflow that updates LastScheduledDate so the NextDate keeps getting created.

Here are the results:

Last Scheduled Date=8/1/2018..... Next Scheduled date gets properly calculated to 10/1/2018. The increment is 2(months).

Last Scheduled Date=10/1/2018... Next Scheduled date gets improperly calculated to 11/30/2018. Expected it to be 12/1/2018.

Then all the rest of the dates are now incorrect falling on the 30th instead of the 1st.

Does anyone know how to tweek this? I like that it rolls to the next year, but the day/month is incorrect.

Day cannot be higher than 28.

Any help appreciated!!

*This post is locked for comments

  • RE: Increment date by x months using AddMonths not calculating correctly

    Hi Carol,

    I have tested the same thing in my teasing environment which is D365.

    1. Added calculated field 'Closed By' to Case

    2. set calculation "AddMonths(2, resolveby)"

    3. publish the changes and set the resolved by date to 01/10/2018

    4. The Closed by date was calculated correctly. (01/12/2018)  

    2671.Untitled.png

    So I don't think there is an issue on the date field calculated field. Please check your calculation formula again. 

    Regards,

    Hasi

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Increment date by x months using AddMonths not calculating correctly

    Great :)

  • Carol J Kelly Profile Picture
    Carol J Kelly 507 on at
    RE: Increment date by x months using AddMonths not calculating correctly

    Thanks. I changed the Behavior from User Local to Date Only on the calculated field as you have it and its working nicely. Missed that setting completely.. was heading to javascript!! LOL

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Increment date by x months using AddMonths not calculating correctly

    Hi Carol,

    I did the similar step for me I am getting expected result . Here is the result.

    CalculatedField.png

    Please match the all the field details with below screenshot  , hope you will get helps from here .

    Scheduled Date Field :

    ScheduledDate.png

    Whole Number :

    Whole-Number.png

    Calculated Date Field :

    CalculatedField.png

    Calculated Date Field conditions :

    CalculatedFieldCondition.png

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans