LastDayoftheMonth()

shabaab_mazhar
Mega Expert

I'm trying to figure out if any one had done to get the last day of the month. I would like to pass the Month and the year and it would return me the last date. Somethign similar to the javascript function as shown below.

 

var date = new Date();

var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);

var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);

1 REPLY 1

Anurag Tripathi
Mega Patron
Mega Patron

Hi Shahbaab,



U can use this to get the last day of month:


var gdt = new GlideDateTime();


gs.print(gdt.getDaysInMonth());




Check this out :


http://wiki.servicenow.com/index.php?title=GlideDateTime#getDaysInMonth.28.29




also see this :


http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#endOfThisMonth.28.29


-Anurag