
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)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.