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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to increment date Month by Month

(0) ShareShare
ReportReport
Posted on by 410

Hi All, I have tried to increment date month by month in a plugin i created, I used the following date method: DateTime.now.AddMonths(1) in a For Loop, Rather than see the date increase by month as expected in the multiple record created in the For Loop, I am see the following;

17/12/2018

17/12/2018

17/12/2018......

Can anyone help me out please. Thank you

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at
    RE: How to increment date Month by Month

    Yes, correct.

    Thanks a lot! That should solve your problem.

  • Victor Onyebuchi Profile Picture
    410 on at
    RE: How to increment date Month by Month

    Spot on Sara, it's my silly mistake. Thank you

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to increment date Month by Month

    Victor,

    The problem is within your loop structure, you are using DateTime.Now.AddMonths(1), when you should be using AddMonths(i) where i is the loop counter.

    For instance, the code should read as below

    DateTime dateVariable = DateTime.Now;

    for (int i = 0; i < 12; i++)

    {

       DateTime modifiedDate = dateVariable.AddMonths(i);

    }

  • Victor Onyebuchi Profile Picture
    410 on at
    RE: How to increment date Month by Month

    hi Priyesh, it gave this error:

    "Date is less than the minumum value supported by CrmDateTime. Actual value: 02/01/0001 00:00:00, Minimum value supported: 01/01/1753 00:00:00 " and i know why, because you took out the DateTime.Now, rathger you used just DateTime.

  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at
    RE: How to increment date Month by Month

    Hi Victor,

    Actually what you need to do is this -

    DateTime myDate = new Date();

    your for loop()
    {

    myDate = myDate.AddMonths(1);
    }

    So that each time, the incremented date is stored.

    Note: Please make my answer as verified if this helped you. Thanks.

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans