There’s plenty of scenarios where counting the number of days between two given date fields is useful in your forms. For example, you might have a form that’s used to register users for a multi-day event or you want to build a form for tracking the number of days an employee has been with your company. Whatever your use case, this tutorial will help you calculate the number of days between two dates with ease.
Gravity Forms Date Time Calculator adds support for date and time calculations in any Gravity Forms field that supports calculations. We can use it to accurately calculate the number of days between two date fields in our form.
Add two Date fields to your form, name them “Start Date” and “End Date”, and set your desired date format.
Add a Number field to your form and name it “Number of Days”. In the Formula box, subtract Start Date’s merge tag from End Date’s merge tag.
That’s all there is to it! You now have a Number field that dynamically displays the number of days based on user input in the Date fields.
Taking This Further
You can do a number of interesting things now that you have this count. For example, you can show another field in the form using conditional logic based on the number of days counted. This has a variety of uses, like offering different pricing structures or a discount once the customer has selected a minimum number of days.
You can use a similar technique to set up age-based pricing with GF Date Time Calculator. Check out the following tutorial on how to set that up:
Do you have any questions on setting this up? Do you have an interesting use case you’d like to tell us about? We’d love to hear them. Leave us a comment below.