• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1639
  • Last Modified:

DateAdd Function

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,

  • 2
1 Solution
To answer your questions in reverse order:

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

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

billy21Author Commented:
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>}
billy21Author Commented:
OIC the <BR> things seem to be a result of copying and pasting and nothing more.

Works fine.  Thanks amg.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now