proposal - custom format for date, timestamp

Started by Pavel Stehulealmost 16 years ago3 messageshackers
Jump to latest
#1Pavel Stehule
pavel.stehule@gmail.com

Hello

I thinking about request on custom datetime format. My first idea is:

a) add new datestyle format "custom"
b) add new GUC variables - custom_date_format, custom_time_format,
custom_timestamp_format

There are some questions:
a) what is good behave when datestyle = custom, but some necessary
custom_*_format is empty?
b) custom format is used for output, have to be used for input too?
c) when input isn't correct for custom format, should be parsed by usual way?

I did some conceptual prototype - see attachment

postgres=# set datestyle to custom;
SET
Time: 0,450 ms
postgres=# select current_date;
ERROR: custom_datestyle_format is empty
postgres=# set custom_datestyle_format to 'Dy Mon YYYY';
SET
Time: 0,409 ms
postgres=# select current_date;
date
--------------
Wed Jun 2010
(1 row)

Time: 0,485 ms

Regards
Pavel Stehule

Attachments:

custom_format.diffapplication/octet-stream; name=custom_format.diffDownload+56-31
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pavel Stehule (#1)
Re: proposal - custom format for date, timestamp

Pavel Stehule <pavel.stehule@gmail.com> writes:

I thinking about request on custom datetime format. My first idea is:

a) add new datestyle format "custom"
b) add new GUC variables - custom_date_format, custom_time_format,
custom_timestamp_format

Ick. Why not just put them in one variable.
datestyle = 'custom yyyy mm dd'
Interrelated GUCs are really painful.

regards, tom lane

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tom Lane (#2)
Re: proposal - custom format for date, timestamp

2010/6/2 Tom Lane <tgl@sss.pgh.pa.us>:

Pavel Stehule <pavel.stehule@gmail.com> writes:

I thinking about request on custom datetime format. My first idea is:

a) add new datestyle format "custom"
b) add new GUC variables - custom_date_format, custom_time_format,
custom_timestamp_format

Ick.  Why not just put them in one variable.
       datestyle = 'custom yyyy mm dd'
Interrelated GUCs are really painful.

I understand, but personally I dislike mix two different values - name
and format together. And what more - we need separate formats for
date, time and timestamp. It is differnet than Oracle because Oracle
uses only one datatype for all.

Regards
Pavel

Show quoted text

                       regards, tom lane