Re: xml queries & date format

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Jef Peeraer" <jef(dot)peeraer(at)telenet(dot)be>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: xml queries & date format
Date: 2008-09-11 10:23:57
Message-ID: 162867790809110323y6439177bje23494e6ad661ee4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2008/9/11 Jef Peeraer <jef(dot)peeraer(at)telenet(dot)be>:
>
>
> On Thu, 11 Sep 2008, Peter Eisentraut wrote:
>
>> Tom Lane wrote:
>> > Jef Peeraer <jef(dot)peeraer(at)telenet(dot)be> writes:
>> > > i am using the xml add-ons, but the date output format seems to be wrong :
>> >
>> > I think the conversion to xml intentionally always uses ISO date format,
>> > because that's required by some spec somewhere.
>>
>> Yes, it follows XML Schema. Which is why the output format is even slightly
>> different from the SQL-mandated ISO format.
> i understand, but that makes it very difficult to change the date format
> afterwards. i simple flag to indicate no date conversion would be
> helpfull....
> >

no, use explicit casting to varchar

-- xml formating style
postgres=# select xmlforest(current_timestamp as date);
xmlforest
-----------------------------------------------
<date>2008-09-11T12:21:44.600512+02:00</date>
(1 row)

postgres=# select xmlforest(current_timestamp::text as date);
xmlforest
--------------------------------------------
<date>2008-09-11 12:22:25.180611+02</date>
(1 row)

postgres=# set datestyle to German ;
SET
postgres=# select xmlforest(current_timestamp::text as date);
xmlforest
----------------------------------------------
<date>11.09.2008 12:22:32.947672 CEST</date>
(1 row)

regards
Pavel Stehule

>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>>
>>
>>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2008-09-11 10:32:51 Re: xml queries & date format
Previous Message Pavel Stehule 2008-09-11 10:19:01 Re: external query VS user function