Search Postgresql Archives

Re: How to get DATE in server locale format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In response to Andrus :
> >You might be able to get what you want with the to_char() function,
> >if setting datestyle doesn't do the trick for you.
> 
> setting datestyle changes style for whole sql statement.
> 
> How to get this in a single conversion in sql statement so that other 
> expressions in same sql statement are not affected.
> 
> to_char() requires hard-coded format.
> Different servers have different locales so that format is not know at 
> application design time.
> 
> How to get localized date for single conversion inside SELECT statement so 
> that it works in different server lc_time settings ?

As Tom said, you can use to_char():

test=*# show lc_time;
   lc_time
-------------
 en_US.UTF-8
(1 row)

test=*# select to_char(current_date, 'TMDay - TMMonth - YYYY');
         to_char
-------------------------
 Monday - January - 2010
(1 row)

test=*# set lc_time = 'de_DE.UTF-8';
SET
test=*# select to_char(current_date, 'TMDay - TMMonth - YYYY');
        to_char
------------------------
 Montag - Januar - 2010
(1 row)


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux