How can I calculate difference between two dates in Days, months, and years?

  • smai
    Asked on October 24, 2016 at 9:33 PM

    Is there a magic formula to make this happen?

    I am trying to create a Warranty Claim form, where the customer inputs the date purchased.

    This will then (hopefully) auto-calculate the period lapsed since purchase in another text box field.

     

    I.e.

    Time lapsed = 3 years, 2 months, 1 day

    = 2 months, 5 days

    = 29 days etc. etc.

     

    The magic calculator doesn't do 'IF' formulas does it?

  • Chriistian Jotform Support
    Replied on October 25, 2016 at 12:32 AM

    You can use the Form Calculation widget to calculate the difference between two dates. 

    1. First, add the form calculation widget.

    How can I calculate difference between two dates in Days, months, and years? Image 1 Screenshot 60

    2. Then input the formula seen below. Here's a guide that can help: How to Perform Calculation in the Form?

    How can I calculate difference between two dates in Days, months, and years? Image 2 Screenshot 71

    The result should be the number of days since the purchased date.

    How can I calculate difference between two dates in Days, months, and years? Image 3 Screenshot 82

    For months, simply add another Form Calculation widget and add the formula below:

    How can I calculate difference between two dates in Days, months, and years? Image 4 Screenshot 93

    Here's the result:

    How can I calculate difference between two dates in Days, months, and years? Image 5 Screenshot 104

    You can also clone my demo form to test it and see it in action here: https://form.jotform.com/62980617429970.

    If you need further assistance, please let us know.
    Regards.