Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Comparing 2 Dates Script

    Hi

    I have the following script

    Code:
    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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?

  • #5
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    The request statement writes the date from the previous page :

    i.e. 12/09/2009


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •