Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer gkaiseril

Have you done any programming?

There have been many similar questions about computing future dates. Have you searched for these items?

First one needs to convert the date character string to the JavaScript date object. Next add 60 days to the date object. Set to the 1st of the month. Finally add 1 month the month of the date object and format the result for display.

One possible custom calculation script for the anniversary date is:

// get the hire date string;

var cHireDate = this.getField("Hire Date").value;

// convert date string to date object;

var oDate = util.scand("mm/dd/yyy", cHireDate);

// add 60 days;

oDate.setDate(oDate.getDate() + 60);

// set date oject to first of the month;

oDate.setDate(1);

// add one month;

oDate.setMonth(oDate.getMonth() + 1);

// format the result;

event.value = util.printd("mm/dd/yyyyy", oDate);

Note the anniversary date field's format is "None".

4 replies

jvavalsAuthor
Participant
September 6, 2016

No programming experience...what you provided worked great.  2 issues...1) how do I block the calculation until "Hire Date" is entered? and 2) the YYYY doesn't advance to 2017 when the +60 days goes past 12/31/2016.

Inspiring
September 6, 2016

Due to one to many "y"'s in the result field format, the year does not even show.

I also see that the month is advanced to the wrong month when the 60th day anniversary occurs on the 1st of the month.

A revised script:

event.value = ""; // clear the result field;

// get the hire date string;

var cHireDate = this.getField("Hire Date").value;

if(cHireDate != "")

{

// convert date string to date object;

var oDate = util.scand("mm/dd/yyy", cHireDate);

// add 60 days;

oDate.setDate(oDate.getDate() + 60);

// set date to 1st of the next month if 60th day anniversary not the 1st;

if(oDate.getDate() > 1)

{

oDate.setDate(1);

// add one month;

oDate.setMonth(oDate.getMonth() + 1);

}

// format the result;

event.value = util.printd("mm/dd/yyyy", oDate);

} // end value not empty;

gkaiserilCorrect answer
Inspiring
September 2, 2016

Have you done any programming?

There have been many similar questions about computing future dates. Have you searched for these items?

First one needs to convert the date character string to the JavaScript date object. Next add 60 days to the date object. Set to the 1st of the month. Finally add 1 month the month of the date object and format the result for display.

One possible custom calculation script for the anniversary date is:

// get the hire date string;

var cHireDate = this.getField("Hire Date").value;

// convert date string to date object;

var oDate = util.scand("mm/dd/yyy", cHireDate);

// add 60 days;

oDate.setDate(oDate.getDate() + 60);

// set date oject to first of the month;

oDate.setDate(1);

// add one month;

oDate.setMonth(oDate.getMonth() + 1);

// format the result;

event.value = util.printd("mm/dd/yyyyy", oDate);

Note the anniversary date field's format is "None".