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

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Convert Month & Year text fields to a date field

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans