I'm having some trouble with time with time zone
equalities in Postgres. timestamp with time zone
equality works how I would expect it to, where if the times are the same after normalizing the timezones, it should be true:
postgres=# select '2013-06-27 12:00:00 -0800'::timestamp with time zone = '2013-06-27 14:00:00 -0600'::timestamp with time zone;
?column?
----------
t
However, the same does not seem to apply to time with time zone
:
postgres=# select '12:00:00 -0800'::time with time zone = '14:00:00 -0600'::time with time zone;
?column?
----------
f
Yet inequalities work how I would expect them to:
postgres=# select '12:00:00 -0800'::time with time zone < '14:01:00 -0600'::time with time zone;
?column?
----------
t
postgres=# select '12:00:00 -0800'::time with time zone > '13:59:00 -0600'::time with time zone;
?column?
----------
t
Is there something I'm misunderstanding about time with time zone
? How can I evaluate for equality in a way that handles time zones the same way timestamp with time zone
equality does?
Here are two ways to evaluate
timetz
equality:The first by adding it to a
date
. The second by using theAT TIME ZONE
construct.But just don't use
time with time zone
. Ever.Postgres supports the type only because it is in the SQL standard. But it is broken by design (cannot consider DST!) and its use is discouraged.
Quoting the manual here: