How to Get Only Date from DateTime in Tableau
Working with dates in Tableau can sometimes feel like a chore, especially when your data source includes a timestamp you don't need. If you have a column full of "DateTime" values (like 1/15/2024 10:30:15 AM) and all you want is the date part (1/15/2024), you're in the right place. This guide will walk you through several practical methods to cleanly extract just the date from a DateTime field in Tableau, helping you simplify your visualizations and analysis.
Why Is Separating the Date Important?
Before diving into the "how," it's helpful to understand the "why." Raw DateTime fields are precise, but that precision can get in the way of meaningful analysis. When you’re trying to see trends over time, you rarely need to know performance by the specific minute or second.
Here are a few key reasons to strip the time from your date field:
For Clear Aggregation: Imagine you want to see total sales for January 15th. If you use a DateTime field, Tableau will see each sale at 10:30 AM, 11:15 AM, and 2:40 PM as unique points in time. By isolating the date, you can properly group all of that day's sales to get a single, aggregated number.
To Simplify Visualizations: A line chart showing website sessions for every second of the day would be an unreadable mess of spikes. Grouping by day creates a clean, understandable trend line that shows meaningful patterns in your data.
To Improve Readability: Dashboards that display metrics for "1/15/2024 12:00:00 AM" are cluttered. Showing just "1/15/2024" is cleaner for reports and makes your work look more professional.
For Accurate Calculations: If you're calculating day-over-day growth or other time-based metrics, you need to compare full days against full days, not 10 AM on Tuesday with 4 PM on Wednesday.
Method 1: The Quickest Fix - Change the Data Type
The simplest way to remove the time component is to tell Tableau to treat the entire field as a date. This is a great quick-and-dirty method if you know you won't need the time information anywhere else in your workbook.
Follow these steps:
Navigate to Your Data Pane: From any worksheet, look at the Data pane on the left side of your screen where your data source fields are listed.
Find Your DateTime Field: Locate the field you want to change (e.g., "Order Timestamp"). You’ll see a small icon next to it that looks like a calendar with a clock, which signifies the DateTime data type.
Click the Icon: Click on that calendar-and-clock icon. A dropdown menu will appear.
Select "Date": From the menu, choose the "Date" option (the one with just a calendar icon).
That's it. Tableau will now ignore the time part of that field throughout your entire workbook. All existing values like "1/15/2024 10:30:15 AM" will simply become "1/15/2024".
Pros: It's incredibly fast and requires no formulas.Cons: This method modifies the data type for the field everywhere. If you need the original timestamp for a different calculation or analysis in the same workbook, this isn't the best option because you lose that information.
Method 2: The Best Practice - Create a Calculated Field
For more flexibility, creating a new calculated field is the recommended approach. This leaves your original DateTime field untouched, giving you a separate, clean date field to use for aggregation and visualizations.
Here are a few different functions you can use to accomplish this.
Using the DATE() Function
The DATE() function is the most direct and common way to convert a DateTime value into a Date value. It simply extracts the date part and discards the time.
How to Create the Calculation:
Right-click on an empty area in the Data pane and select "Create Calculated Field..."
Give your new field a descriptive name, like "Order Date" or "Transaction Date".
In the formula editor, type the following function, replacing
[Your DateTime Field]with the name of your specific field:
For example, if your field is named "Order Timestamp", the formula would be:
Click "OK."
You’ll now see a new field in your Data pane called "Order Date" with a clean calendar icon next to it. You can drag this new field into your views for perfect daily aggregation.
Using the DATETRUNC() Function
The DATETRUNC() function is another powerful tool. Instead of just removing the time, it "truncates" the date to the first moment of a specified date part (like a day, week, month, or year). When you truncate to 'day', it effectively sets the time to midnight (12:00:00 AM).
This is useful when you need to standardize all timestamps from a single day to the exact same starting point.
How to Create the Calculation:
Create a new calculated field as described above.
Name it something like "Date (Truncated)".
Use the following formula:
For example, if the original value is "1/15/2024 10:30:15 AM", this function will return "1/15/2024 12:00:00 AM". While it still technically returns a DateTime value, every record from that day will have the exact same value, making it perfect for grouping.
Pro tip: After creating the DATETRUNC calculated field, you can still format it to appear as just a date. Right-click the newly created field in the Data pane, go to Default Properties > Date Format..., and choose a format that doesn't show the time.
Using MAKEDATE() for More Granular Control
This is a less common approach for this specific task, but it’s a brilliant function to know. The MAKEDATE() function builds a date from separate integer values for year, month, and day. You can use it by extracting each part from your DateTime field first.
How to Create the Calculation:
Create a new calculated field.
Name it something like "Reconstructed Date".
Use the following formula, which pulls out the year, month, and day and then puts them back together as a date:
While DATE() is much more efficient, MAKEDATE() is a great tool for situations where you might need to adjust one of the date parts during the calculation (e.g., creating a report for the first day of the month for every transaction).
Putting It Into Practice: A Quick Example
Let's say you have a dataset of online sales with an Order Time field. You want to see total sales by day for the last month.
The Wrong Way: Using the Raw DateTime Field
If you drag the raw Order Time field to Columns and Sales to Rows, Tableau will either give you a messy, over-detailed view if you set it to "Exact Date," or it might aggregate by year by default, requiring lots of clicking to drill down. Analyzing daily trends becomes a headache because each transaction time is a unique data point.
The Right Way: Using Your New Date Field
Create a calculated field named "Order Date" using the formula:
DATE([Order Time]).Drag the new "Order Date" field to the Columns shelf. Tableau will likely default to showing YEAR(Order Date).
Right-click the "Order Date" pill in the Columns shelf and select the "Day" option that is listed below year, quarter, and month. It will show something like "May 8, 2016".
Drag your
Salesmeasure to the Rows shelf.
You now have a clean, beautiful bar or line chart showing the total sales for each individual day. This simple change turns chaotic data into a clear, actionable insight.
Bonus Method: Using Split in the Data Source Tab
In some cases, your DateTime data might come into Tableau as a text string (e.g., "01/15/2024 10:30:15 AM"). If this happens, Tableau has a handy "Split" feature you can use.
Go to the Data Source tab in the bottom-left of your Tableau window.
Find your text-based DateTime column.
Click the little dropdown arrow on the column header.
Select "Split" or "Custom Split...".
If you use "Custom Split", you can tell Tableau to split the column using the space (" ") character as the separator. This will create two new columns: one with the date and one with the time.
You can then change the data type of the new date column to "Date" and rename it.
This method isn't as foolproof as a calculated field (as it depends on the consistency of the string format), but it's another great tool to have in your back pocket.
Final Thoughts
Turning a detailed DateTime field into a simple Date is a fundamental skill in Tableau that instantly cleans up your reports and simplifies your analysis. For a quick fix, changing the data type works wonders, but the best practice for maintaining data integrity and flexibility is to create a new calculated field using the DATE() or DATETRUNC() functions.
Ultimately, getting clean, daily insights shouldn't be a tedious process. That's why we built Graphed to do the heavy lifting for you. Instead of worrying about data formatting and formulas, you can connect your data sources like Google Analytics, Shopify, and Facebook Ads, and just ask a question in plain English, like, "show me my daily sales and ad spend for the last 30 days." We handle the rest, instantly turning your request into a real-time dashboard so you can focus on making decisions, not wrangling data.