Bruce Momjian <br...@momjian.us> writes:
> On Fri, Feb 15, 2013 at 09:27:40PM +0000, nick.bax...@gmail.com wrote:
>> 9.9.2. indicates that date_trunc can be called with a date value (which will
>> be cast to a timestamp). And regardless of the input, that the result will
>> be of type timestamp. When I call it with a date, I get a timestamp with
>> time zone instead, as indicated by the psql output.

> That documentation often uses timestamp when it means timestamp with
> time zone.  Not sure why that is.

Well, what the subsection about date_trunc says is "source is a value
expression of type timestamp or interval".  Up at the very top of the
page, it says

        All the functions and operators described below that take time
        or timestamp inputs actually come in two variants: one that
        takes time with time zone or timestamp with time zone, and one
        that takes time without time zone or timestamp without time
        zone. For brevity, these variants are not shown separately.

So omitting mention of date_trunc(timestamptz) is not inconsistent.
If we wanted to fix that the page would get quite a bit longer, but
perhaps not much more illuminating.

It strikes me that the problem is in the parenthetical remark in 9.9.2:
"(Values of type date and time are cast automatically to timestamp or
interval, respectively.)".  Since there are both timestamp and
timestamptz alternatives available, the parser will actually prefer to
cast a date input to timestamptz, that being the preferred type in this
category.  Maybe we should say "timestamp with time zone" there, though
I can see that confusing people in a different way.

                        regards, tom lane


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

Reply via email to