pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to get localized to_char(DATE) output
7+ messages / 3 participants
[nested] [flat]
* How to get localized to_char(DATE) output
@ 2010-05-05 22:26 Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Kellerer @ 2010-05-05 22:26 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm trying to get the output of the to_char(date, text) method in German but I can't get it to work:
My understanding is, that I need to set lc_time for the session in order to change the language used by to_char(), but this does not seem to work for me:
postgres=> select version();
version
-------------------------------------------------------------
PostgreSQL 8.4.3, compiled by Visual C++ build 1400, 32-bit
(1 Zeile)
postgres=> select to_char(current_date, 'Mon');
to_char
---------
May
(1 Zeile)
postgres=> set lc_time = 'German';
SET
postgres=> select to_char(current_date, 'Mon');
to_char
---------
May
(1 Zeile)
postgres=>
Postgres' messages are in German, but not the output of to_char()
After changing lc_time to 'German' I would have expected 'Mai' instead of 'May'
What am I mising?
Regards
Thomas
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get localized to_char(DATE) output
@ 2010-05-05 22:51 Tom Lane <tgl@sss.pgh.pa.us>
parent: Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 2010-05-05 22:51 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-sql
Thomas Kellerer <spam_eater@gmx.net> writes:
> I'm trying to get the output of the to_char(date, text) method in German but I can't get it to work:
I think you need 'TMMon' to get a localized month name.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get localized to_char(DATE) output
@ 2010-05-06 06:42 Thomas Kellerer <spam_eater@gmx.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Kellerer @ 2010-05-06 06:42 UTC (permalink / raw)
To: pgsql-sql
Tom Lane, 06.05.2010 00:51:
> Thomas Kellerer<spam_eater@gmx.net> writes:
>> I'm trying to get the output of the to_char(date, text) method in German but I can't get it to work:
>
> I think you need 'TMMon' to get a localized month name.
>
> regards, tom lane
>
Ah! Silly me. Now that you write this I can see it in the manual ;)
The manual says the value for lc_time is OS dependent and indeed "set lc_time = 'German'" does not work on Solaris.
Is there a way to get a list of allowed values for lc_time for a specific installation?
Thanks for your help
Thomas
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get localized to_char(DATE) output
@ 2010-05-06 09:57 Jasen Betts <jasen@xnet.co.nz>
parent: Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 7+ messages in thread
From: Jasen Betts @ 2010-05-06 09:57 UTC (permalink / raw)
To: pgsql-sql
On 2010-05-06, Thomas Kellerer <spam_eater@gmx.net> wrote:
> Tom Lane, 06.05.2010 00:51:
>> Thomas Kellerer<spam_eater@gmx.net> writes:
>>> I'm trying to get the output of the to_char(date, text) method in German but I can't get it to work:
>>
>> I think you need 'TMMon' to get a localized month name.
>>
>> regards, tom lane
>>
> Ah! Silly me. Now that you write this I can see it in the manual ;)
>
> The manual says the value for lc_time is OS dependent and indeed "set lc_time = 'German'" does not work on Solaris.
>
> Is there a way to get a list of allowed values for lc_time for a specific installation?
"man -k locale" would be my starting point (for anything POSIXish)
Looks like "locale -a" does it on linux, that may be worth a try.
"de_DE" is the locale for German as used in Germany.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get localized to_char(DATE) output
@ 2010-05-06 10:46 Thomas Kellerer <spam_eater@gmx.net>
parent: Jasen Betts <jasen@xnet.co.nz>
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Kellerer @ 2010-05-06 10:46 UTC (permalink / raw)
To: pgsql-sql
Jasen Betts, 06.05.2010 11:57:
>> The manual says the value for lc_time is OS dependent and indeed "set lc_time = 'German'" does not work on Solaris.
>>
>> Is there a way to get a list of allowed values for lc_time for a specific installation?
>
> "man -k locale" would be my starting point (for anything POSIXish)
>
> Looks like "locale -a" does it on linux, that may be worth a try.
>
> "de_DE" is the locale for German as used in Germany.
>
>
>
Thanks for the answer. Is there a way to get this information from within a SQL statement?
Regards
Thomas
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get localized to_char(DATE) output
@ 2010-05-06 14:22 Tom Lane <tgl@sss.pgh.pa.us>
parent: Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 2010-05-06 14:22 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-sql
Thomas Kellerer <spam_eater@gmx.net> writes:
> Jasen Betts, 06.05.2010 11:57:
>>> Is there a way to get a list of allowed values for lc_time for a specific installation?
>> Looks like "locale -a" does it on linux, that may be worth a try.
> Thanks for the answer. Is there a way to get this information from within a SQL statement?
No. Postgres doesn't know anything about that. "locale -a" should work
on pretty much any Unix-ish system, but I dunno what the equivalent on
Windows would be.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get localized to_char(DATE) output
@ 2010-05-06 14:37 Thomas Kellerer <spam_eater@gmx.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Kellerer @ 2010-05-06 14:37 UTC (permalink / raw)
To: pgsql-sql
Tom Lane, 06.05.2010 16:22:
>>> Looks like "locale -a" does it on linux, that may be worth a try.
>
>> Thanks for the answer. Is there a way to get this information from within a SQL statement?
>
> No. Postgres doesn't know anything about that. "locale -a" should work
> on pretty much any Unix-ish system, but I dunno what the equivalent on
> Windows would be.
>
OK, thanks a lot
Regards
Thomas
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2010-05-06 14:37 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-05-05 22:26 How to get localized to_char(DATE) output Thomas Kellerer <spam_eater@gmx.net>
2010-05-05 22:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-05-06 06:42 ` Thomas Kellerer <spam_eater@gmx.net>
2010-05-06 09:57 ` Jasen Betts <jasen@xnet.co.nz>
2010-05-06 10:46 ` Thomas Kellerer <spam_eater@gmx.net>
2010-05-06 14:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-05-06 14:37 ` Thomas Kellerer <spam_eater@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox