Search code examples
postgresqltimestamptimestamp-with-timezone

error when inserting timestamp with milliseconds


I've the following table:

CREATE TABLE public.forex_historical_tick
(
    symbol char(7) NOT NULL,
    date timestamp(3) with time zone NOT NULL,
    ask double precision NOT NULL,
    bid double precision NOT NULL,
    volume integer NOT NULL
)
;

I want to insert a data with a timestamp with timezone with millisecond precision. This is the query:

insert into public.forex_historical_tick (symbol, date, ask, bid, volume) values ('EUR/USD', '2019-01-01 1:70:23.725-05', 1.145980, 1.146820, 0);

I'm obtaining an error:

ERROR:  ERRORE:  valore del campo date/time fuori dall'intervallo consentito: "2019-01-01 1:70:23.725-05"
LINE 1: ...ymbol, date, ask, bid, volume) values ('EUR/USD', '2019-01-0...
                                                             ^


SQL state: 22008
Character: 94

The message says that the value of date/time field is out of available interval (I don't know the exact error message in English).

Since I've created the timestamp with timestamp(3) I was sure that I was able to store also milliseconds. What I'm doing wrong?


Solution

  • Look at the number of minutes in 1:70:23.725. There are only 60 minutes in an hour.