Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Calculate the Number of Days Between Two Dates With Gravity Forms

Calculate the number of days between two given date fields and populate this number into a field on the form.

October 22, 2019 by Scott Buchmann 1 Comment

This article requires the GP Date Time Calculator perk. Buy Gravity Perks today to get this perk plus 33 other premium Gravity Forms plugins!

  • View the Plugin
  • Buy Gravity Perks

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.

Steps

  1. Add Start and End Dates
  2. Calculate the Number of Days

Step 1 – Add Start and End Dates

Add two Date fields to your form, name them “Start Date” and “End Date”, and set your desired date format.

Start Date

Step 2 – Calculate the Number of Days

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.

Count the Number of Days

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.

Number of Days Discount

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:

How to Set Up Age Based Pricing

GF Date Time Calculator isn’t just limited to calculating days. It can count in any time unit, such as years, weeks or months, using the Date Calculation Unit setting.

Questions? Comments?

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.

Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 32+ essential add-ons for Gravity Forms with support you can count on.

  • View All Perks
  • Buy Gravity Perks

Filed Under: How To date field gp date time calculator product field

Comments

  1. Edi Michael says

    November 25, 2019 at 11:07 am

    Hi David, I wonder if this addon works with the feature of calculating the target date with source date and user-specified date count?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories

  • How To (63)
  • News (21)
  • Plugins (14)
  • Releases (7)
  • Resource (3)
  • Snippets (58)
  • Tutorials (57)
  • Updates (104)

Recent Posts

  • How to Update Posts with Gravity Forms
  • Gravity Wiz Weekly #104
  • The Complete Guide to Using Gravity Forms With Zapier
  • Gravity Wiz Weekly #103
  • Show Active Forms by Default on Form List

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2021 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account