Re: date_trun() with timezones? (was Re: TIME column manipulation/comparison hangups)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bill Moran <wmoran(at)collaborativefusion(dot)com>
Cc: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: date_trun() with timezones? (was Re: TIME column manipulation/comparison hangups)
Date: 2008-11-03 19:46:04
Message-ID: 16063.1225741564@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill Moran <wmoran(at)collaborativefusion(dot)com> writes:
> Not quite. As shown in the examples, date_trunc() works fine on
> TIME WITHOUT TIME ZONE, but there's no such function for TIME WITH
> TIME ZONE.

Well, actually there's no date_trunc for time either:

regression=# \df date_trunc
List of functions
Schema | Name | Result data type | Argument data types
------------+------------+-----------------------------+-----------------------------------
pg_catalog | date_trunc | interval | text, interval
pg_catalog | date_trunc | timestamp with time zone | text, timestamp with time zone
pg_catalog | date_trunc | timestamp without time zone | text, timestamp without time zone
(3 rows)

However, the interval version of the function can capture the time case
because there's an implicit cast from time to interval:

regression=# select casttarget::regtype,castcontext,castfunc::regprocedure from pg_cast where castsource = 'time'::regtype;
casttarget | castcontext | castfunc
------------------------+-------------+----------------------------------------
interval | i | "interval"(time without time zone)
time with time zone | i | timetz(time without time zone)
time without time zone | i | "time"(time without time zone,integer)
(3 rows)

There's no implicit cast from timetz to interval, which I suppose is
because it would be an information-losing transform.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-11-03 19:53:30 pg_casts view (was Re: date_trun() with timezones? (was Re: TIME column ...))
Previous Message Bill Moran 2008-11-03 19:39:22 date_trun() with timezones? (was Re: TIME column manipulation/comparison hangups)