JavaScript Last day of Previous month

D-pk
D-pk used Ask the Experts™
on
I am very new to Javascript and Hyperion Interactive reporting.

I need to display last day of the previous month in my text box as default when the form loads. The following code is for displaying sysdate.

Thanks!
var the_date = new Date()
the_mon = (the_date.getMonth() + 1)+""
if(the_mon.length <2)
{
the_mon = '0'+the_mon
}
the_dt = the_date.getDate()+""
if(the_dt.length <2)
{
the_dt = '0'+the_dt
}
ActiveDocument.Sections["Dashboard"].Shapes["TextBox1"].Text = (the_mon) + "/" + the_dt + "/" + the_date.getFullYear()

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
this gets last day of last month:

var d = new Date();
var month = d.getMonth();; // January
var dd = new Date(2008, month, 0);
alert(dd); // last day in January

Open in new window

The above is incorrect:
var d = new Date();
var dd = new Date(d.getYear(), d.getMonth(), 0);
alert(dd); 

Open in new window

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial