Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DateAdd Function

Posted on 2004-08-15
3
Medium Priority
?
1,637 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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

636 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