Sidebar

How can I get the last day of a month?

0 votes
217 views
asked Aug 22, 2017 by brandon-w-8204 (31,870 points)
I have a date and need to know the last day of that month

1 Answer

0 votes

Here is a function you can use to get the last day of the month:

function getLastDayOfMonth(stringDate) {
   var date = qie.deduceDate(stringDate);
   var cal = java.util.GregorianCalendar.getInstance();
   cal.setTime(date);
   return cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
}

Here is an example of how to call it:

qie.debug('2/20/2017: ' + getLastDayOfMonth('2/20/2017'));

answered Aug 22, 2017 by brandon-w-8204 (31,870 points)
...