Calculate Completion Date from Start Date Field

I have a production start date field. I also have a estimated completion date field that I want to basically add 30 days to the production start date field.

I seen the=is thread but it is from current date. Instead of current date, I want the calculation to come from another field in the same form. Any ideas?

Would this solution work for you?

That takes the data that was selected in the first datepicker, adds 30 days to it, and that is the minimum for the second datepicker. You may not want people to be picking dates though, just showing them the date 30 days in the future?

How do the date field work and look in your form?

This would work, except I’m getting parse errors trying to implement it.

Also, I don’t quite understand how it works.

I have my form ID = 5 and fieldID = 8 (this is the field of the original date).

How do I tell it what field I want to add the 30 days to?

In this line:

jQuery('#input_12_12').datepicker('option', 'minDate', dateMin).datepicker('setDate', dateMin)

The input_12_12 is form 12, and field 12. Your line code will look like this to add 30 days to the date that was submitted in field 8 of form 5 and use that in field 9 (this may need to be updated in the code to match the field in your form that should get 30 days added to it):

<script>
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
  if ( formId == 5 && fieldId == 8 ) {
    optionsObj.minDate = 0;
    optionsObj.onClose = function (dateText, inst) {
      dateText = new Date(dateText);
      dateMin = new Date(dateText.getFullYear(), dateText.getMonth() + 1,dateText.getDate());
      jQuery('#input_5_9').datepicker('option', 'minDate', dateMin).datepicker('setDate', dateMin);
    };
  }
  return optionsObj;
});\
</script>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.