ORA-01840: input value not long enough for date format

3.8k views Asked by At

I'm trying to insert a column in oracle which is in "TIMESTAMP(6) WITH TIME ZONE" format.

Below is the insert SQL:

INSERT INTO print_temp 
( print_before_tswtz ) 
VALUES 
( 
  TO_TIMESTAMP_TZ( TRUNC(SYSDATE) + INTERVAL '1' DAY -  INTERVAL '1' SECOND ) 
  +   
  NUMTODSINTERVAL('5','DAY') 
) ;

Below is the error which I get; Error report:

SQL Error: ORA-01840: input value not long enough for date format 01840. 00000 - "input value not long enough for date format"

Could anyone please help me with this error? Thanks!

1

There are 1 answers

0
uudecode On

Timestamp keep's parts of second, so you can use something like this:

INSERT INTO print_temp ( print_before_tswtz ) VALUES (TO_TIMESTAMP_TZ( TRUNC(SYSDATE) + INTERVAL '1' DAY - INTERVAL '1' SECOND||'.000000000' ) +
NUMTODSINTERVAL('5','DAY') ) ;