locked
Jquery Comparison Date RRS feed

  • Question

  • User-893002196 posted

    Hi,

    I have 24 Hr Date format:-

    var dtPredLateCurrent = new Date($('input[name="ReferDate_' + idx + '"]').val() + " " + $('input[name="Start_' + idx + '"]').val()+":00");  //2019-12-10 00:00:00
    var dtPredLateSt = new Date($('input[name="ReferDate_' + idx + '"]').val() + " " + decimalToTime("@ViewData["LATEOTStart"]")+":00"); //2019-12-10 22:00:00
    var dtPredLateEnd = new Date($('input[name="ReferDate_' + idx + '"]').val() + " " + decimalToTime("3")+":00"); //2019-12-10 03:00:00

    if (dtPredLateSt < dtPredLateCurrent < dtPredLateEnd) {
    ...do something
    }

    I getting error: Invalid Date

    Please help.

    Regards,
    Micheale

    Tuesday, March 31, 2020 9:17 AM

All replies

  • User475983607 posted

    micinie2020, the shared code is incomplete.  The View, Action, and decimalToTime() function are missing,  The community cannot review the most important parts of the code.

    Can you share the input values?  If you are not sure, set a break point and single step over your JavaScript code to find the input values.  You can also view the HTML source.  Is decimaltoTime() a custom function you wrote?  Have you properly tested the function? 

    It seems you are not using standard debugging tools because you have not drilled down far enough into the code.  You shared source of the error but did not take the time to investigate the source of the data to make sure the data is a valid date.

    Tuesday, March 31, 2020 12:02 PM
  • User-474980206 posted

    your date format is invalid. should be '2019-12-10T00:00:00' or '2019/12/10 00:00:00'

    Thursday, April 2, 2020 3:01 PM