PostgreSQL dates function output to a french language

我是研究僧i 提交于 2021-01-28 06:23:01

问题


How can I output the result of PostgreSQL dates function as to_char to french language, for example the output of:

select to_char(current_date, 'Day') ;

should be (a french name for a day):

Mardi 

instead of english of day (e.g. Monady)


回答1:


You would need to set the display of date/time (LC_TIME) to french, and to query not the Day but rather the localizable day TMDay using the TM prefix.

show LC_TIME;
SET LC_TIME = 'French';
select to_char(current_date, 'TMDay') ;
 to_char
---------
 Mardi
(1 row)



回答2:


The following works on Ubuntu 16.04 Server, with english language set-up

first we need to add system support for French templating with the command:

sudo locale-gen fr_FR.utf8

then restart postgresql service:

sudo systemctl restart postgresql

then log in to psql

SET LC_TIME = 'fr_FR.utf8';
select to_char(current_date, 'TMDay') ;
to_char
---------
Mardi
(1 row)


来源:https://stackoverflow.com/questions/51731602/postgresql-dates-function-output-to-a-french-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!