convert year YYYY to year YY
In the script at lines 1 thru 7, this.getField("date.Closing.Actual.Date") has a date format of mm/dd/yy and its value determines the yyyy value of this.getField("date.YrOfClosing") which has a yyyy custom date format. this.getField("date.Prior1231") has a date format of mm/dd/yy . I need to use the yyyy value to set the yy value of this.getField("date.Prior1231") to 12/31/yy of the year before yyyy (where mm/dd will always be 12/31). Ex: if the source field value is == 2018 then the value of this.getField("date.Prior1231") should be 12/31/17.
1. var actual = this.getField("date.Closing.Actual.Date").value; //mm/dd/yy format
2. var d = util.scand("mm/dd/yy", actual);
3. var yearOfClosing = this.getField("date.YrOfClosing"); //YYYY format.
4. yearOfClosing.value = d.getFullYear( ); //extracts year in YYYY format
5. var f = d.getFullYear().toString().substr(-2); //Ex: change 2018 to 18.
6. var priorDec31 = this.getField("date.Prior1231");
7. priorDec31.value = new Date("December 31, " + (f - 1));
This throws this error: Invalid date/time: please ensure that the date/time exists. Field [ date.Prior1231 ] should match format mm/dd/yy
