---
title: "Tableau: Calculating Accumulated Date Part Difference in Tableau"
description: Want to know how to calculate accumulated time difference between different date parts in Tableau? Check out this blog to learn more.
---

[DDBM Blog ](https://www.ddbm.com/blog)

# [Tableau: Calculating Accumulated Date Part Difference in Tableau](https://www.ddbm.com/blog/2023/08/28/tableau-calculating-accumulated-date-part-difference-in-tableau)

 Geschreven door [Emre Oktay](https://www.ddbm.com/blog/author/emre-oktay) | 27 Aug, 2023

In the world of [data visualization](https://www.theinformationlab.nl/oplossingen/data-lezen-en-visualiseren/) and analysis, [Tableau](https://www.theinformationlab.nl/technologie/tableau/) has emerged as a powerful tool that empowers users to extract insights from complex datasets. One common scenario involves working with datetime fields and calculating their differences. In this blog post, we’ll dive into a technique to calculate the difference between two datetime fields in an accumulated manner, providing a comprehensive understanding of the period in terms of **days, hours, and minutes**.

## **Understanding the Need for Accumulated Date Part Differences**

Imagine you’re analyzing a dataset containing records of customer service response times. You have two datetime fields: “Datetime From” and “Datetime To”. While calculating the difference in hours or days might provide some insight, it doesn’t capture the entire story. What if the response time crosses over a day boundary or even multiple days? To address this, we can calculate the accumulated difference in various date parts.

## **Step-by-Step Guide**

Let’s walk through the process of calculating the accumulated difference between two datetime fields, keeping track of days, hours, and minutes, using Tableau.

### **1. Create a Calculated Field**

Start by creating a calculated field that calculates the difference between the two datetime fields. To do this, right-click on the “Data” pane and select “Create Calculated Field.” For this calculation, we will only calculate the total minute difference between the two datetime fields;

 Let’s call this field “**Minute Difference**“

### **2. Define the Calculation**

In the calculated field formula, you’ll use the DATEDIFF function to calculate the difference between the two datetime fields. The DATEDIFF function takes three arguments: the date part you want to calculate, the start datetime, and the end datetime. Dial the following calculation in;

`DATEDIFF('minute', [Datetime From], [Datetime To])`

### **3. Calculate Accumulated Values**

Now, let’s create calculated fields to calculate the accumulated difference in days, hours, and minutes. These fields will use the WINDOW_SUM function to accumulate the differences over rows. We can call these fields “ACC Days”, “ACC Hours” and “ACC Minutes”

**Days:**

```

```

**Hours:**

```

```

**Minutes:**

```
[Minute difference] - [ACC Days] * 1440 - [ACC Hours] * 60
```

### **4. Display the Results**

Drag the calculated fields for accumulated days, hours, and minutes onto your visualization canvas. You can choose to display these values on a table, chart, or dashboard, depending on your preference.

### **5. Formatting the Output**

To present the results in a human-readable format (“X days Y hours Z minutes”), you can use additional calculated fields. Here’s an example formula for creating a formatted text field:

```
STR([ACC Days]) + ' days ' + STR([ACC Hours]) + ' hours ' + STR([ACC Minutes]) + ' minutes'
```

When everything is put together, our final calculation should look something like this:

In my example, I am using a very basic table with the different datetime stamps per 20 different IDs.

## Final Remarks

By calculating the accumulated difference between two datetime fields in terms of days, hours, and minutes, you gain a more insightful perspective on periods that cross date boundaries. This technique can provide a deeper understanding of data, particularly in scenarios where time intervals are critical.

Thank you for reading this blog. Also check out our other [blogs](https://www.theinformationlab.nl/blogs/) page to view more blogs on [Tableau](https://www.theinformationlab.nl/technologie/tableau/), [Alteryx](https://www.theinformationlab.nl/technologie/alteryx/), and [Snowflake](https://www.theinformationlab.nl/technologie/snowflake/).

**[Work together](https://www.theinformationlab.nl/en/ons-team/) **with one of our consultants and maximize the effects of your data. 

[**Contact us**](https://www.theinformationlab.nl/en/contact/), and we’ll help you right away

[Volledig bericht weergeven](https://www.ddbm.com/blog/2023/08/28/tableau-calculating-accumulated-date-part-difference-in-tableau)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Emre Oktay"
  },
  "dateModified" : "2026-02-11T11:16:51.631Z",
  "datePublished" : "2023-08-27T22:00:00Z",
  "headline" : "Tableau: Calculating Accumulated Date Part Difference in Tableau",
  "image" : {
    "@type" : "ImageObject",
    "height" : 1282,
    "url" : "https://www.ddbm.com/hubfs/Imported_Blog_Media/time-3435879_1920-2-1.jpg",
    "width" : 1920
  },
  "mainEntityOfPage" : "https://www.ddbm.com/blog/2023/08/28/tableau-calculating-accumulated-date-part-difference-in-tableau",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "DDBM Blog"
  }
}
```