[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


setDate(31) for AUG not working - shows Aug 1st

Posted on 2007-11-15
Medium Priority
Last Modified: 2008-02-01
Hi All,
I need to compare a date of Aug 31st, and a year against today's date
and the below does give me Aug 31st, it gives me Aug 1st,

   var dteLimit = new Date();
  alert('Initial Setting');

   dteLimit.setDate(30);  ----gives Aug 30
   dteLimit.setDate(14);  ----gives Aug 14
   dteLimit.setDate(31);  ----Does NOT give Aug 31
Question by:bcarlis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 25

Accepted Solution

James Rodgers earned 200 total points
ID: 20290579
cahnge teh sequence

it doesnt understand how toi handle 31 when it does already know the month
LVL 17

Assisted Solution

contactkarthi earned 200 total points
ID: 20290589
it tries to set 31 for nov which will be dec 1

after that you set month as aug so you see aug 1

set the month first and then the date

Author Comment

ID: 20290623
Ha! that makes sense!
Duh.. Thank you so much!
LVL 54

Expert Comment

ID: 20290698
Good answer guys!  Just to add a little follow up the same principle is true if you are setting the year.  Make sure you do that first before any changes to month or day.  It won't always matter but can make a big difference at times, especially in February. :)


Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question