Issue with JavaScript Date

Sort:
You are not authorized to post a reply.
Author
Messages
tommyg-006
Basic Member
Posts: 11
Basic Member

    Good Afternoon All,

    I am hoping somebody else has run into this issue before.  I seem to be having with a JavaScript calculation in IPA.  We are trying to take today's date (i.e 10/15/2019) and move it forward to December so the date range starts at 12/01/2019.  However, when the script runs it returns a date of 00/01/2020.  The script works for every other month in the calendar except for 12/1.  Below is the script that we have in IPA:

     

    Evaluating JavaScript expression jsDate=CurrentDateTR

     

    CurrentFirstofMonth=jsDate.setDate(1); to value 1569960755400

    Evaluating JavaScript expression //current date

    jsDate = CurrentDateTR;

     

    //set forward 3 months

    jsDate.setMonth(jsDate.getMonth()+3);

     

    //set day to the first

    jsDate.setDate(1);

     

    FirstofMonth = jsDate;

     

    var month =FirstofMonth.getMonth();

     

    if (month<10){

    month = "0" + month.toString()

    }

     

    var day = FirstofMonth.getDate();

     

    if (day<10){

    day = "0" + day.toString()

    }

     

    var year = FirstofMonth.getFullYear();

     

    NewHireDateStartPT=month.toString()+'/'+day.toString()+'/'+year.toString(); to value 00/01/2020

     

    There is a 2nd calculation after this script that calculates the last day of the month, which comes up correctly with 12/31/2019.  Any thoughts as to what we might be missing in the script?  Thank you in advance!

    David Williams
    Veteran Member
    Posts: 1127
    Veteran Member
      In JavaScript, the first month is zero. 0=Jan 1=Feb 2=Mar
      David Williams
      You are not authorized to post a reply.