...

View Full Version : Comparing 2 Dates Script



bidbud
12-09-2009, 01:29 PM
Hi

I have the following script



function timeDifference(laterdate,earlierdate) {
var difference = laterdate.getTime() - earlierdate.getTime();

var daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24

document.write('difference = ' + daysDifference + ' day/s ');
}

var laterdate = ?;
var earlierdate = ?;

timeDifference(laterdate,earlierdate);
//--></script>



and would like to insert my datein and dateout values where the ? marks are above in red.

I can call these variables into the form on the page using <%=Request("datein")%> but how do I call a variable into the script above ?

Thanks

Philip M
12-09-2009, 02:41 PM
var laterdate = new Date(2009,12,3); // YYYY MM DD
var earlierdate = new Date(2009,11,28);


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

bidbud
12-09-2009, 03:08 PM
Thanks I have tried that and it does work but now I need to get the date in and dateout values that are stored from the previous page.

I can write them to the screen by using <%=Request("datein")%> but I am not sure how to put this value into the function.

Spudhead
12-09-2009, 04:27 PM
When you use <%=Request("datein")%> to write the value from the previous page to your screen, what, exactly gets written to your page source code?

bidbud
12-09-2009, 04:53 PM
Hi

The request statement writes the date from the previous page :

i.e. 12/09/2009



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum