output format for dates

Started by Adrian Maierover 23 years ago3 messagesgeneral
Jump to latest

So, here comes my question: is it possible to create a new
custom datestyle and set it as default ?

Browsing the sources, i've found a function EncodeDateOnly() in
src/backend/utils/adt which seems to be the function that generates
strings representing dates.

It seems easy to add a 'case' statement for a new datestyle.
But, i guess that won't be enough.

Where else should I add the new datestyle, so that i'll be able to
use it with SET DATESTYLE ?

Thanks in advance,
Adrian Maier (am@fx.ro)

#2Bruce Momjian
bruce@momjian.us
In reply to: Adrian Maier (#1)
Re: output format for dates

am@fx.ro wrote:

So, here comes my question: is it possible to create a new
custom datestyle and set it as default ?

Browsing the sources, i've found a function EncodeDateOnly() in
src/backend/utils/adt which seems to be the function that generates
strings representing dates.

It seems easy to add a 'case' statement for a new datestyle.
But, i guess that won't be enough.

Where else should I add the new datestyle, so that i'll be able to
use it with SET DATESTYLE ?

7.3 will have SET DATESTYLE:

test=> set datestyle to 'iso,european';

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#2)
Re: output format for dates

wsheldah@lexmark.com wrote:

Will setting the DATESTYLE to ISO allow it to accept dates in the ISO
format '2002-09-23T10:54:32', including the 'T' between the date and the
time? I have a client app. that handles dates in that format, and currently
I have to change the 'T' to a space before inserting or updating it into a
table. Thanks,

Yes, I think that was added as well:

test=> select timestamp '2002-09-23T10:54:32';
timestamp
---------------------
2002-09-23 10:54:32
(1 row)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073