Solved

DateAdd Function

Posted on 2004-08-15
3
1,632 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
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

821 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