Avatar of D-pk
D-pkFlag for United States of America

asked on 

JavaScript Last day of Previous month

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

JavaScript

Avatar of undefined
Last Comment
D-pk
Avatar of darren-w-
darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image

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

ASKER CERTIFIED SOLUTION
Avatar of darren-w-
darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of D-pk
D-pk
Flag of United States of America image

ASKER

Thanks
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo