All Forums Database
superjuanito88 17 posts Joined 05/12
06 Feb 2013
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
 

ocirej23 10 posts Joined 04/11
06 Feb 2013

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

KS42982 137 posts Joined 12/12
07 Feb 2013

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
You must sign in to leave a comment.