Loading

Combine DATE and TIME to TIMESTAMP in Amazon Redshift

Julkaisupäivä: Sep 1, 2026
Edellytykset
Tableau Desktop, Tableau Prep Builder, Tableau Server, Tableau Cloud, Amazon Redshift
Tehtävä

When connected to Amazon Redshift, you want to combine a DATE column and a TIME column and convert them into a TIMESTAMP data type.

Because Tableau does not natively support the database TIME data type and Amazon Redshift does not support a direct CAST from TIME to TIMESTAMP, simply concatenating or casting these columns can result in errors such as:

"ERROR: cannot cast type time without time zone to timestamp without time zone".

Vaiheet

To resolve this issue, use one of the following options.

Option 1: Using Tableau Prep Builder

  1. Add a Clean step to your flow.
  2. Create a calculated field using the following formula:
    MAKEDATETIME([date_column], [time_column])
  3. Verify that the data type of the newly created field is set to Date & Time.

Option 2: Using Tableau Desktop

  1. On the Data Source page, select New Custom SQL.
  2. Concatenate the date and time columns as a string and cast them as a TIMESTAMP using a query like the following:
    SELECT CAST(date_column || ' ' || time_column AS TIMESTAMP) AS date_time_cast FROM your_table
    Alternatively:
    SELECT (date_column + time_column) AS date_time_cast FROM your_table

Option 3: Handling at the Database Level

  • Work with your Database Administrator (DBA) to create a view in Amazon Redshift that pre-converts the columns into a TIMESTAMP type, and connect Tableau to that view.
Lisäresurssit

For more information on separating time from a Date & Time field, see the following article:

Isolate Time from Date and Time Field


Please note that, as described in the following article, you cannot use TIME data type columns in Tableau Desktop directly via drag-and-drop:

Fields with TIME Data Type Not Imported Into Tableau Desktop for MS SQL Server

Knowledge-artikkelin numero

005393489

 
Ladataan
Salesforce Help | Article