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 :
Microsoft Dynamics CRM (Archived)

How to get month number from date filed using calculated fields?

(0) ShareShare
ReportReport
Posted on by 307

Hi Experts,

Can we get month number from date field using calculated field?

For example:

3/23/2015----->3

Please suggest your ideas.

Thanks in Advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I'm sorry but that's not possible with Calculated Fields. You will have to develop plugin or javascript to get month number in separated field.

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at

    No, it's not possible with calculated fields.

  • Suggested answer
    Community Member Profile Picture
    on at

    Create calculated field ("Month") in the entity, Data Type should be "Whole Number" and in the Field Type "Edit", then provide the below condition and action.

    IF.. THEN

    CONDITION (Optional)

    ACTION

      Set Month to TRIMRIGHT(Now(),7)

    Hope this should work.

  • Seenivasan M Profile Picture
    307 on at

    Hi Madhan,

    Thanks for your response.

    I followed your steps but i am receiving following error message.

    "You can't use Now(),which is of type dateTime,with the current function"

  • Suggested answer
    Community Member Profile Picture
    on at

    Seeni,

    Here is a link that contains calculated field of Whole number storing the value of "# of days" and you case is also similar to storing the whole number but not finding difference between days.

    ledgeviewpartners.com/.../using-calculated-fields-in-dynamics-crm-2015

    Hope this will work.

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    It is not possible to get the month from a date field, using calculated field.

  • Community Member Profile Picture
    on at

    I've managed to do so with calculated fields.

    First I added a date and time field and set it as 1/1/2000 0:00. Let's say this field's name is DEFAULT_DATE.

    Next I've added a calculated field as WholeNumber and calculated it as "DiffInMonths(DEFAULT_DATE, Now()) - 228" to get current month. To extract a month from different field, replace the field name with "Now()" and you should get your data.

    The same is with years: "DiffInYears(DEFAULT_DATE, Now()) + 1999" and the result should be this year.

  • Suggested answer
    DDNash Profile Picture
    5 on at

    This here is close for getting the current month :

    "DiffInMonths(DEFAULT_DATE, Now()) - 228"

    where DEFAULT_DATE can be any year with January date (1/1/2000 makes checking it easier)

    However the 228 is only good for one year and the month you get is off by 1 (Now month - 1). To get the accurate month you could do:

    "DiffInMonths(DEFAULT_DATE,Now()) - (DIFFINYEARS(DEFAULT_DATE, Now()) * 12) + 1"

    Of course this is a calculated field and you have all of the field refresh limitations.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans