How to add days to date

  • plott
    Asked on September 21, 2017 at 2:02 PM

    I am trying to add some days (from another field) to a date (from a datepicker) based on this:

    https://www.jotform.com/answers/986233-Date-calculation-Adding-63-days-on-the-selected-date

    However, my example doesn't work.

    I'd like calc2 to contain the addition of grunt + calc3

    Could you have a look?

  • aubreybourke
    Replied on September 21, 2017 at 3:31 PM

    Yes its possible. I cloned your form and have it working here:

    https://form.jotformpro.com/72636038757970


    You were nearly right. But the calculation field needs to look like this:

    How to add days to date Image 1 Screenshot 20

    Note: If you click on a field here in the calculation it changes colour. Brown indicates a String of text. While black indicates a number. So you first add the numbers in brackets and the result is fed to the dateString function, which returns a textual representation of the date.


  • plott
    Replied on September 21, 2017 at 6:27 PM

    OK, I've now added another calculated field to my form (Week #1).  From my eye it appears to be identical to Payroll date, but using a hard-coded number rather than a field.

    What am I doing wrong?

  • jonathan
    Replied on September 21, 2017 at 9:35 PM

    I reviewed your form on my browser and I can see the field Week#1 do have the correct calculated value base on the formula.

    How to add days to date Image 1 Screenshot 40

    and

    How to add days to date Image 2 Screenshot 51


    output:

    How to add days to date Image 3 Screenshot 62


    Can you please confirm this is resolved already? Let us know if still not.

    Thanks.

  • plott
    Replied on September 22, 2017 at 7:07 AM

    Yes, I was able to resolve it, but only by adding another field and adding two fields, rather than adding a field and a number.  Should I be able to add a date + a number?

    Thanks for your help!

  • candy
    Replied on September 22, 2017 at 10:42 AM

    I have also cloned your form on my side in order to find another workaround. 

    I have seen that first, you have to calculate "Week One Off Set" and then, you should calculate the "Week #1" depends on it, so that's why you need to have double fields for this kind of calculation. So, I couldn't find any possible workaround to calculate those values only with a single field. 

    For detailed information, please check the following guide: https://www.jotform.com/help/443-Mastering-Date-and-Time-Calculation 

    If you need any assistance, do not hesitate to contact us.

    Thank you.