Invalid Timestamp

Database

Invalid Timestamp

Goodnight

I have a problem doing a CAST in this query to execute, get the error invalid timestamp.
SELECT

(CAST( (CAST(TRIM(Stg.Fecha_Ejecucion_OOSS) AS CHAR(10)) || ' ' || CAST(TRIM(Stg.Hora_Ejecucion_OOSS) AS CHAR(8)))

AS TIMESTAMP(0))) POSTSALES_TRANSACTION_Err

FROM DWH_VIEW_STAGE.VS2701 Stg
Tags (2)
2 REPLIES

Re: Invalid Timestamp

Hi,

Please check if the result of the concatinated values is in proper format before casting to timestamp.

Re: Invalid Timestamp

Try like below (assuming the DATE format is MM/DD/YYYY. If not then, you can change it accordingly)

SELECT 
(CAST( (CAST(TRIM(Stg.Fecha_Ejecucion_OOSS) AS CHAR(10)) || ' ' || CAST(TRIM(Stg.Hora_Ejecucion_OOSS) AS CHAR(8)))
AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYBHH:MI:SS')) POSTSALES_TRANSACTION_Err
FROM DWH_VIEW_STAGE.VS2701 Stg