Javascript Date Object

Discussion in 'ASP General' started by C, Sep 5, 2003.

  1. C

    C Guest

    Hi,

    I take ina series of date inputs from the user.

    I use below JavaScript to parse String into a Date Object
    and then I get the Day part and compare the day part.

    The date entered for elFPD is 1/1/2003
    The date entered for elBalloon is 12/1/2003

    The day I get back for elFPD is 3
    and teh day I get back for elBalloon is 1.

    Anyone know why this is?

    MY date settings are English(US)

    function CheckDates(){

    var elFPD = new Date
    (document.frmDefease.txFPD.value);
    var elDef = new Date
    (document.frmDefease.txDefClose.value);
    var elBalloon = new Date
    (document.frmDefease.txBalloon.value);


    if (elFPD > elBalloon)
    {
    alert('First Payment Date must not
    exceeed Balloon Date');
    document.frmDefease.submit=false;
    }
    else
    {

    if (elFPD > elDef)
    {
    alert('First Payment Date
    must not exceeed Defeasance Date');

    document.frmDefease.submit=false;

    }
    };

    //check Day of FPD against Day of Balloon Date
    var FPDDay;
    var BalloonDay;
    FPDDay = elFPD.getDay();
    BalloonDay = elBalloon.getDay();


    if(FPDDay != BalloonDay)
    {
    alert('First Payment Date
    day must be the same as Balloon Date day');

    }

    }
     
    C, Sep 5, 2003
    #1
    1. Advertising

  2. C

    Dan Brussee Guest

    On Fri, 5 Sep 2003 04:26:40 -0700, "C" <> wrote:

    >Hi,
    >
    >I take ina series of date inputs from the user.
    >
    >I use below JavaScript to parse String into a Date Object
    >and then I get the Day part and compare the day part.
    >
    >The date entered for elFPD is 1/1/2003
    >The date entered for elBalloon is 12/1/2003
    >
    >The day I get back for elFPD is 3
    >and teh day I get back for elBalloon is 1.
    >


    blah blah blah

    > //check Day of FPD against Day of Balloon Date
    > var FPDDay;
    > var BalloonDay;
    > FPDDay = elFPD.getDay();
    > BalloonDay = elBalloon.getDay();
    >
    >
    > if(FPDDay != BalloonDay)
    > {
    > alert('First Payment Date
    >day must be the same as Balloon Date day');
    >
    > }
    >
    >}


    Get the ol' Javascript book out I think. The getDay() method of a date
    object returns the day of week. 1/1/2003 is a Wednesday (Day number
    3), while 12/1/2003 is a Monday (Day number 1). I think what you are
    looking for is the getDate() method, which returns the day of month.
     
    Dan Brussee, Sep 5, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    619
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,295
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    531
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    734
    Richard Heathfield
    Nov 8, 2003
  5. Matt
    Replies:
    11
    Views:
    415
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...

Share This Page