Search code examples
timestampteradatautcteradata-sql-assistant

Importing Timestamp Values from a .txt file into an equivalent column (UTC timestamp) in a Teradata Table


I have Timestamp values in a column 'Ride_Time' in a .txt file. An example of a value in the 'Ride_Time' column is 6/13/2016 9:39. I am trying to create a table in Teradata using Teradata SQLA by importing the values in the 'Ride_Time' column in the .txt file (using the 'Import Data' option and inserting the values from the 'Ride_Time' column to an equivalent column in my new Teradata table. Below is my create table query,

CREATE TABLE Ride_Info
(
Ride_ID VARCHAR(50),
ride_time TIMESTAMP FORMAT 'YYYY-MM-DDbHH:MI:SS',

);

I keep getting the 'Invalid Timestamp' error. Can someone help me with this?


Solution

  • Your input data doesn't match the FORMAT of the target column (solution: apply/change the correct format) and Teradata is fussy regarding single digits (solution: RegEx to add missing leading zeroes). This should work

    Cast(RegExp_Replace(?,'\b([0-9])\b', '0\1') AS TIMESTAMP(0) FORMAT 'mm/dd/yyyyBhh:mi')