add date into url as parameter

Posted on 2014-03-05
Last Modified: 2014-03-05
I have the following script that redirects a user to a web site.
I need to add yesterday's date to the end as paramater txtStartDate, i format 03/04/2014.  This way, each time someone clicks the link, the resulting page is already filtered for them.

<script type="text/javascript">
window.location.href = ""
Question by:drelinger
  • 2
LVL 32

Accepted Solution

Big Monty earned 500 total points
ID: 39907013
LVL 32

Expert Comment

by:Big Monty
ID: 39907032
of course, to format it, you'll need to come up with some code for that as well:

<script type="text/javascript">
function getTommorrowsDate() {
var newDate = new Date() - 1;
var dd = newDate;
var mm = newDate.getMonth();

var yyyy = newDate.getFullYear();
if( dd< 10){ dd='0'+dd }
if( mm < 10){ mm='0'+mm }
return = mm+'/'+dd+'/'+yyyy;

window.location.href = "" + getTommorrowsDate()

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

920 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

14 Experts available now in Live!

Get 1:1 Help Now