Comaprission of dates for a year in JavaScript


I will call a method closed, so that it will be easy for me to recognize it, in that I will use the tab name because as I have declared with in the tab name and a English date, I see another method from where I am calling it. I am displaying like this, if financial year has closed on March 31st exactly than the next date will automatically reflect from first of the April this is what is happening in this method

Check CloseDate()
{
    var OpDtd = new Date(Tab.findControl("OpDt_txtDateInEnglish").
value);
    var ClDtd = new Date(Tab.findControl("ClDt_txtDateInEnglish").
value); 
    var tempClose = newDate(ClDtd.getFullYear(),ClDtd.getMonth(),
ClDtd.getDate());
    var tempOpen = new Date(OpDtd.getFullYear(),OpDtd.getMonth(),
OpDtd.getDate());
    var one_day=1000*60*60*24;
    var ddiff = Math.ceil
((tempClose.getTime()-tempOpen.getTime())/(one_day));
    if(ddiff==365||ddiff==364)
    return 0;
    else
    return 1;
    else
if(CheckCloseDate()==1)
    {
        oEvent.needPostBack = false;
        AlertMessageBox("Please enter valid Period");  
        return false;
    }
}

I need to validate this method. I will check this using the validating method.


Similar Articles