• 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,

Bill
0
billy21
Asked:
billy21
  • 2
1 Solution
 
amg42Commented:
To answer your questions in reverse order:

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

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

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

Works fine.  Thanks amg.
0

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