Thread: Store dates in database in different format

Store dates in database in different format

From
RPK
Date:
I am using pgsql 8.2.3 on windows XP. I noticed that dates are store in
'Date' columns of a table in "yyyy-mm-dd" format whereas I want to store it
in "dd-MMM-yyyy" format. Can I change this?
--
View this message in context:
http://www.nabble.com/Store-dates-in-database-in-different-format-tf3659046.html#a10223882
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: Store dates in database in different format

From
Bill Moran
Date:
In response to RPK <rpk.general@gmail.com>:
>
> I am using pgsql 8.2.3 on windows XP. I noticed that dates are store in
> 'Date' columns of a table in "yyyy-mm-dd" format whereas I want to store it
> in "dd-MMM-yyyy" format. Can I change this?

They're not stored in that format, they're just displaying in that format.

Here's a good place to start reading:
http://www.postgresql.org/docs/8.2/static/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT

--
Bill Moran
http://www.potentialtech.com

Re: Store dates in database in different format

From
Jeff Davis
Date:
On Fri, 2007-04-27 at 11:09 -0700, RPK wrote:
> I am using pgsql 8.2.3 on windows XP. I noticed that dates are store in
> 'Date' columns of a table in "yyyy-mm-dd" format whereas I want to store it
> in "dd-MMM-yyyy" format. Can I change this?

First of all, you're talking about the input/output format, not the
storage format. There's no reason to store the dates differently.

Here's some documentation that can help you with displaying dates like
you want:

http://www.postgresql.org/docs/8.2/static/runtime-config-client.html
(see the DateStyle config)
http://www.postgresql.org/docs/8.2/static/functions-datetime.html

You can also create your own type if that's helpful.

Regards,
    Jeff Davis