DATE type output does not follow datestyle parameter

From: "MauMau" <maumau307(at)gmail(dot)com>
To: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: DATE type output does not follow datestyle parameter
Date: 2013-07-26 12:31:12
Message-ID: 3157168929514D1291BBE83AFE2AE711@maumau
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

The description of datestyle parameter does not seem to match the actual
behavior. Is this a bug to be fixed? Which do you think should be
corrected, the program or the manual?

The manual says:

DateStyle (string)
Sets the display format for date and time values, as well as the rules for
interpreting ambiguous date input values. For historical reasons, this
variable contains two independent components: the output format
specification (ISO, Postgres, SQL, or German) and the input/output
specification for year/month/day ordering (DMY, MDY, or YMD). ...

And says:

http://www.postgresql.org/docs/current/static/datatype-datetime.html

8.5.2. Date/Time Output
The output of the date and time types is of course only the date or time
part in accordance with the given examples.

After doing "SET datestyle = 'Postgres, MDY'" on the psql prompt, I did the
following things on the same psql session:

1. SELECT current_timestamp;

now
----------------------------------
Wed Jul 24 10:51:00.217 2013 GMT
(1 行)

This is exactly as I expected.

2. SELECT current_date;
I expected the output "Wed Jul 24 2013" or "Jul 24 2013", but I got:

date
------------
07-24-2013
(1 行)

This does not follow the above statement in 8.5.2. This output is created
by EncodeDateOnly() in src/backend/utils/adt/datetime.c.

Regards
MauMau

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Loïc Rollus 2013-07-26 13:00:11 Trigger and deadlock
Previous Message amulsul 2013-07-26 08:32:24 Re: How to do incremental / differential backup every hour in Postgres 9.1?