Re: date out of range for timestamp

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: date out of range for timestamp
Дата
Msg-id 13702.1293586580@sss.pgh.pa.us
обсуждение исходный текст
Ответ на date out of range for timestamp  (David Rericha <d.rericha@healthcareoss.com>)
Список pgsql-admin
David Rericha <d.rericha@healthcareoss.com> writes:
> I have a 21 GB database in version 8.4.5 that is giving me a curious
> error when I perform a query on one of the tables:

> select count(*) from moms_outside_report where outreport_date <=
> '12/10/2010';
> ERROR:  date out of range for timestamp

Did you really truly type the query just like that, or was the
comparison "constant" actually a placeholder of some sort?
The only way I can see for that query to invoke the places where
that error message can be produced is if what you were really
doing was "date_column <= timestamp_constant".  And an unmarked
literal string being compared to a date column would *not* get
interpreted as a timestamp.  But if you were issuing this through
some client-side driver that was marking the parameter as being of
type timestamp, it's believable.

Anyway, assuming that the query really is date <= timestamp, the problem
is you've got some wacko date value in the table, and when the backend
tries to promote that date to timestamp so it can do the comparison, it
fails.  Per the fine manual, dates go out to about 5 million AD while
timestamps only reach about 300 thousand AD.  Try

select * from moms_outside_report where outreport_date >
'290000-01-01'::date or outreport_date < '4700-01-01 BC'::date;

to find the bad values.  Or maybe better, search for anything outside
the range of what you think the entries ought to be.

            regards, tom lane

В списке pgsql-admin по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: date out of range for timestamp
Следующее
От: Tom Lane
Дата:
Сообщение: Re: date out of range for timestamp