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)

Convert Month & Year text fields to a date field

(0) ShareShare
ReportReport
Posted on by 20

I have Users that want to enter Year and Month in 2 separate fields to log a payment record.   I then need to take that information and convert it to the last day of the given month in a date field format.  With limited knowledge in JS, I am somewhat at a loss.  I did concatenate the two fields to one text field, for example, "Jan" and "2018" becomes "01/31/2018" (User is okay with Feb always defaulting to the 28th), and thought if I could grab that text field to popluate the newDate field.  This is where I draw a blank.

Any suggestions...or just tell the User to get used to entering in a date format?

Thanks for any suggestions.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    It is always recommended users to train/educate on the out of box functionalities as this will help reduce your custom development which increases project cost/ maintenance. So my first recommendation would be to request user to use the out of box date field.

    If user still wants separate month, year then you can achieve this by adding multiple checks like

    ============================================

    var newDate = new Date();

    newDate.setYear(1986);

    if(month == "Jan")

    {

        d.setDate(31);

        d.setMonth(0);

    }

    else if(month == "Feb")

    {

        d.setDate(31);

        d.setMonth(1);

    }

    else if(month == "March")

    {

        d.setDate(31);

        d.setMonth(2);

    }

    else if(month == "Apr")

    {

        d.setDate(30);

        d.setMonth(3);

    }

    …

    …

    =====================================

    Hope this helps.

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