Re: How to convert US date format to European date format ?

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Condor <condor(at)stz-bg(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to convert US date format to European date format ?
Date: 2013-04-10 13:17:19
Message-ID: 5165665F.3070505@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/10/2013 06:03 AM, Condor wrote:
> Hello ppl,
>
> I have a database where the previous owner use US date format in date
> fields:
>
> 2009-02-18
>
> Is there a way how to convert the fields in European format 18-02-2009.
> I mean existing date in records. What's will be happened if I change format
> in postgresql.conf ?

The dates are stored as a non formatted value. What you are seeing is
the output formatting:

http://www.postgresql.org/docs/9.2/interactive/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT

In other words the data in the fields will not be converted.

If you want a European style formatting then you can set the
DateStyle='SQL,DMY':

test=> set datestyle='SQL,DMY';
SET
test=> SELECT now()::date;
now
------------
10/04/2013
(1 row)

This can be done as needed or by setting it in postgresql.conf

>
>
> Cheers,
> Hristo S.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message JotaComm 2013-04-10 13:19:40 Re: how to find which tables required indexes in postgresql
Previous Message Thomas Kellerer 2013-04-10 13:15:21 Re: How to convert US date format to European date format ?