How to calculate the difference between two dates and a fee based on those dates

  • DownwardDogATX
    Asked on May 4, 2016 at 2:10 PM

    I am trying to create a form for my dog sitting business where the user can input the dates and it will automatically calculate their total and let them pay through PayPal. Is there a way to do that? I've been playing with it for a while and I can't seem to figure it out :/

  • David JotForm Support
    Replied on May 4, 2016 at 3:27 PM

    You can achieve your requirement with using our Form Calculation widget.

    First you need to add 2 date fields to your form. Then add Form Calculation widget and configure it to calculate the number between two dates. 

     

    How to calculate the difference between two dates and a fee based on those dates Image 1 Screenshot 40

     

    If you want to calculate the difference between today and the other date field you can set first date field’s value to default and hide it. This will set date field value to today and it will never be seen on your form. 

     

    How to calculate the difference between two dates and a fee based on those dates Image 2 Screenshot 51

    How to calculate the difference between two dates and a fee based on those dates Image 3 Screenshot 62

     

    You can find additional information about Form Calculation widget here.

    Once you have the number of days calculated, you can add another calculation widget to calculate the total fee or you can include the fee calculation in your original calculation.  When you have your total, you can pass that total to PayPal for payment processing:

    https://www.jotform.com/help/275-How-to-pass-a-calculation-to-a-payment-field