Learn how to calculate the days between dates easily! Our step-by-step guide will help you quickly find the difference between any two dates. Start now!
Approximate read time: 7 minutes
Finding the number of days between two dates is handy whether you want to create a cost estimator for a vacation property or help expecting parents count down their baby's due date.
Here are just a few examples of how an online date calculator can add value to your website:
- ⏳ Deadline calculator
- 🎫 Event countdown
- 🫄 Pregnancy calculator
- 📦 Shipping date calculator
But if you landed on this article, you probably already have a reason you want to know how many days there are between two dates. So, we'll get right down to business.
How to calculate the number of days between dates
In this tutorial, we will make a simple calculator to estimate the cost of renting a bike for a certain duration. 🚲 Ready to get rolling? Let's go!
Step 1: Install and activate Formidable Forms Pro
To make a custom date calculator for your website, you first need Formidable Forms Pro on your WordPress site. If you don't have the plugin, click the button below to grab your license.
The date calculation feature is included in the business plan or above.
Once you've installed and activated the plugin, go to Formidable → Add-Ons. Then click to install and activate the Datepicker Options add-on.
All set? Super! Let's start creating our calculator!
Step 2: Create your date calculator form
From the WordPress dashboard, head on over to Formidable → Forms. Next, click the blue + Add New button to create a new form.
If you'd like to start with a premade form, choose our pregnancy due date calculator template, age calculator template, or deadline calculator form.
For today's step-by-step guide, we'll make a basic calculator form from scratch instead. So, click Create a blank form to open up the drag and drop form builder.
Now, let's drag two Date fields and a # Number field into our form. We'll click on each field to edit its name, description, and layout.
For this example, why don't we make the first date field the bike pickup date and the second the date when the customer will return the bike? That'll make it easy to calculate the number of days between the two dates.
Then, we can multiply by the daily rental rate.
Step 3: Add field calculations
Next, it's time to make our form do some math.
Click on the number field to open its field settings. In the example below, our number field is called "Duration of rental."
Under the Advanced section of the Field Options tab, insert the formula for your date calculation.
Since we only want to find the total number of days for the rental period, we subtract the Pickup date field (or start date) from the Drop off date field (aka end date).
Since we want to give visitors a price estimate for their bike rental, we'll add a few other form fields so they can pick the type of bike they want and then see the rental cost.
When you're happy with your form, click Save and Preview to test your custom calculator!
Step 4: Publish your calculator
It's all downhill from here! 🚵
To publish your date calculator, open up the WordPress post or page where you want to display it. Then, add the Formidable Forms block in the editor and select your calculator form from the dropdown menu that appears.
Way to go! You now have a way to calculate the difference between two dates on your site! 🙌
Here's how our bike rental calculator ended up:
Go beyond counting days, months, or years
Formidable's datepicker calculations can do much more than tell you how many days are between two dates.
You can also:
- Countdown to an event from the current date
- Add or subtract days from a chosen date
- Include the start or end day in your calculations
Want to use the current date in your calculator?
Nothing could be easier! Just click the date field in your form, then set the default value for that field to be the current date in the settings on the left side of the screen.
You could also set the field to Read only so it can't be modified or hide the field so visitors don't see it.
It may not make much sense for our bike rental form, but it's ideal for countdowns. ⏲️
For example, here's a wedding countdown we made to instantly show how many days away a future date is from today.
Add or subtract days from a chosen date
With Formidable Forms, you can quickly make a calculator to find the date a certain number of years, months, weeks, or days from a specific date.
Check out our tutorial on how to calculate the day from a date to instantly find a past or future date!
Include the last day in your calculations
Sometimes, you may want to include the first or last day when counting the days between two dates. This is especially important for creating a visa calculator or a similar time calculator tool.
Luckily, it's really easy to do with Formidable. Add a "+1" to your formula.
And then, ta-da! Your calculator now includes these days.
Instantly find the number of days between two dates
Whether you're looking to streamline your event planning, simplify travel arrangements, or conquer complex time-based challenges, Formidable Forms can help you create a custom online date calculator for your WordPress website.
Forget fighting with formulas in Excel or Google Sheets. You don't need to know anything about HTML or JavaScript, either.
So what are you waiting for? Add value to your site and multiply your traffic by adding a date calculator now.
Try out our calculator and WordPress form maker to see how simple they are. If you don't love it, we have a 14-day money-back guarantee, no questions asked!
And follow our Facebook, Twitter, and YouTube for more date and time tips!
Leave a Reply