Solved

DateAdd Function

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at 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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now