Re: date out of range for timestamp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Rericha <d.rericha@xxxxxxxxxxxxxxxxx> 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

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux