Solved

DateAdd Function

Posted on 2004-08-15
3
1,635 Views
Last Modified: 2008-10-13
How do I add days to a date in javascript?  What I want to do is simply add 7 days to a date.

Also can I convert a string to a date?  the date I'll be using will be coming in as a string formatted dd mmm yyyy

Thanks in advance,

Bill
0
Comment
Question by:billy21
[X]
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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
amg42 earned 500 total points
ID: 11803929
To answer your questions in reverse order:

var d = new Date("15 Aug 2004")

with (d) {
      setDate(getDate() + 7);
}

0
 
LVL 6

Author Comment

by:billy21
ID: 11803948
The <BR> things appear to be html.  I get a syntax error.  My function looks like this...


function MoveRight()
{
      var d = document.all;
      
      var dt = new Date(d.hidStartDate.value);<BR>
      with (dt) {<BR>     setDate(getDate() + 7);<BR>}
      
      
      
}
0
 
LVL 6

Author Comment

by:billy21
ID: 11803959
OIC the <BR> things seem to be a result of copying and pasting and nothing more.

Works fine.  Thanks amg.
0

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

695 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