---
title: "How to compare and calculate two dates in a Zap"
description: "Compare and calculate dates across apps with Zapier's built-in Formatter tool. "
image: "https://images.ctfassets.net/lzny33ho1g45/zapier-formatter-guide-p-img/03c11a2d66243e8d4dc9db80b183eb61/Hero.jpg"
---

# How to compare and calculate two dates in a Zap

Compare and calculate dates across apps with Zapier's built-in Formatter tool. 

Dates can be deceptively tricky for humans_ and_ computers. Though computers are arguably better at comparing and calculating dates, they can only do so if the date formats match. (I wish I had that excuse.)

Date formats aren't an issue if you're working within the same app, but what if you're trying to automate date-related information across your work tools? Luckily, Zapier has a [built-in tool called Formatter](https://zapier.com/blog/zapier-formatter-guide/) that can automatically compare and calculate dates across your favorite apps.

This tutorial will show you how to use Formatter's _Date Compare_ function in a Zap—what we call Zapier's automated workflows—so you can accurately forecast deadlines, your workload, and other planning for your business. 

### 
Table of contents

- [What is Compare Dates in a formatter step?](#compare)
- [Before you begin](#before)
- [How to compare dates with a formatter step](#how)
- [Use the results elsewhere](#use)

## What is Compare Dates in Formatter?

Formatter is Zapier's built-in utility tool for Zaps. It lets you transform app information into the format you need for later Zap steps, such as [manipulating text](https://zapier.com/blog/zapier-formatter-guide/) or [adjusting date formats](https://zapier.com/blog/format-datetimes/).

Formatter has several date functions, one of which is _Compare Dates_. You can tell Zapier the two dates you want to compare, and Formatter will let you know if those dates fall on the same day, as well as the duration between those dates.

When you might use Compare Dates: 

- **You want to calculate the time between two dates.** Some apps may do this for you already, but what if you want to perform your own calculations? For example, you could compare the time a lead spent between deal stages to understand how long it takes to close a sale, then use that to calculate your team's capacity to hit certain sales goals.
- **You want to reduce how often a Zap runs based on app changes.** Some spreadsheet and database apps can start a Zap too often because they might use timestamp fields to judge whether a record is new or updated. You can compare those timestamps and use a [filter](https://zapier.com/blog/filter-by-zapier-guide/) or [path step](https://zapier.com/blog/zapier-paths-conditional-workflows/)—[available on paid Zapier plans](https://zapier.com/pricing)—to determine the next steps. We'll cover [how to do that later on](#conditional).
- **You want to check if certain data matches up between apps.** Not sure if the date from your project management tool matches up with your personal to-do? You can compare the dates, then tell your Zap what to do if something doesn't match up.

## Before you begin

For this tutorial, we'll assume you're familiar with how Zapier works. If not, don't worry: [It's free to sign up ](https://zapier.com/sign-up/)for a Zapier account. We also have a [guide to creating your first Zap](https://zapier.com/learn/zapier-quick-start-guide/). 

Then, make sure you're [in the Zap editor](https://zapier.com/app/editor), where you can create and edit Zaps. You can either use an existing Zap you've created or build a new one from scratch. Just make sure your new Zap is created up to the point where you want to compare two dates—the dates don't have to come from the same app, either.

For this example, I'm setting up a Zap to flag any last-minute tasks in Asana. I'll use Formatter to compare the start and the end dates and determine how much time I have for a task.

You can still follow along if you want to compare dates from a different app. Our formatter step will come right after our trigger—the event that starts a Zap. 

## How to compare and subtract two dates

Click the **plus sign** to add a step to your Zap. Then, search for and select** Formatter by Zapier **as the app, **Date / Time** as the event, and click** Continue**. 

Click on the dropdown beneath _Transform_ and select **Compare Dates**. 

The editor will prompt you to provide start and end dates. Your start date doesn't have to be an "official" start date, as labeled in your app. You can also think of your start date as the main comparison point. 

To compare dates, map a dynamic value from a previous Zap step. Dynamic values are field values that change each time a Zap runs, depending on the information a Zap step receives, such as the due date for a new task. 

Click on the **Start Date** field to see a dropdown menu of data from previous Zap steps. Search for and select the dynamic value you want to use.

**Note:** If you type in a static date, Zapier will interpret that you want to use the same date _every_ time your Zap runs. 

Then, select the dynamic value you want to use as your end date. 

Don't worry if your comparison dates are in different formats. Zapier will do its best to interpret the correct date. However, if you'd like, you can also tell Zapier the format for your start and end dates.  

Once you're done, click **Continue,** and then **Test action**. You'll see a success message with Formatter's results, which will include the following: 

- The duration between the two dates, down to the second if your dates also included times.
- **Dates swapped:** If your end date came before your start date, Zapier lets you know that the dates were swapped to calculate the time difference.
- **Same dates:** Zapier will provide a true or false result if the dates are the same. If the dates are the same but the time is different, Zapier will still consider it the same date.

Check the Formatter results carefully to make sure the dates were interpreted correctly. 

If something is off, return to the previous step, make adjustments, and keep testing until you get the correct result. 

## Use your results in your Zap

Now you can use the comparison results elsewhere in your Zap. Click the **plus button** to add another step to your Zap. 

Then, set up your action using your Formatter results. For example, you could pass on the difference between the two dates to another app. 

### Create conditional Zaps

You can also use your Formatter results with other built-in Zapier tools to create more complex workflows.  

#### **Use a filter or a path step**

Don't want your Zap to run if your start and end dates are the same? Select the fields from the Formatter step you want to use in a filter or path, then select the condition you want to evaluate. 

In the example below, I set up rules for a path if assigned an Asana task with a quick deadline. The path rules will only let this Zap continue if the start and due dates are the same _or _I have less than five days to complete the task. 

Use _(Boolean)_ conditions for the _Same Dates_ and _Swapped Dates_ fields and _(Number)_ conditions for the time difference. This will ensure your filter or path rules evaluate those fields correctly.

### **Perform a math operation**

You can also use your date comparison results in a spreadsheet-style formula or math operation. Add another Formatter step, select the **Number** transformation, then [the function you want to use](https://help.zapier.com/hc/en-us/articles/8496212590093#all-number-transformations-0-1). 

I'm using Formatter's _Perform Math Operation _function in the example below. I want to calculate the hours it would take each day to complete an Asana task. I've set up this step to divide the estimated hours for this task by the number of days Formatter calculated earlier. 

Now I can use my hours-per-day calculation elsewhere in my Zap. 

No matter how you use your Formatter results, remember to test subsequent Zap steps and make sure it's on!

## **Calculate date-related data confidently with Formatter **

Don't let math mistakes or calendar quirks get in the way of accurate data. With Formatter's Compare Dates function, you can automatically check and calculate dates within your favorite apps. 

Want to automate more of your work with dates and numbers? Check out other ways you can use Formatter:

- [How to change date and time formats in your text automatically](https://zapier.com/blog/format-datetimes/)
- [Automatically find and match related data across apps](https://zapier.com/blog/find-match-data-across-apps/)