DATE type output does not follow datestyle parameter

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

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-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-07-24 12:45:52 Re: [bug fix] PITR corrupts the database cluster
Previous Message Fujii Masao 2013-07-24 11:35:49 Re: Backup throttling