July 19, 2021, 2:21pm
I'm trying to show in my dynamic table the date information with this format: month year (example: Janeiro 2021). So, I want the month in portuguese.
The original format is that (with the non needed day and hour):
To get this result, I'm using:
date_trunc ('month', mês) AS mês,
When I try to extract only the month and year information, I get the result in english:
To get this result I used:
to_char(mês, 'month YYYY') AS mês
to_char(date_trunc('month', mês), 'month YYYY') AS mês
Can I get this information the way I want it?
July 19, 2021, 3:46pm
July 19, 2021, 3:52pm
Yes, I already read it. But I could not get the months in portuguese, only in english
July 19, 2021, 4:17pm
to_char(date_trunc('month', mês), 'TMmonth YYYY') AS mês
got answer from
which seems to be from "
Table 9-25. Template Pattern Modifiers for Date/Time Formatting" in https://www.postgresql.org/docs/9.6/functions-formatting.html
TMMonth or set the
lc_time in the connection string - sounds like your database is probably created with English as the default.
Read everything here: https://www.postgresql.org/docs/current/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIMEMOD-TABLE
July 22, 2021, 1:42pm
TMMonth did not work... and I tried
lc_time but got this message:
ERROR: permission denied to set parameter "lc_time" to "pt_BR.UTF8"
I've tried this:
SET lc_time TO 'pt_BR.UTF8';
@Helena Well, you would need to talk to your database administrator, so they can help you setting the correct language.
July 22, 2021, 2:16pm
I have the administrator profile and searching the settings, I found the following:
Do I need to configure another setting?
@Helena You are using SQL, so the Metabase instance does not apply here. You need to contact your database administrator, since you are getting a permission error from the database.
July 22, 2021, 2:34pm
Hmmmmmm... ok! I'm talking to him now. Thank you!
You need to enable your language in Metabase Postgres server.
Edit your /etc/locale.gen and uncomment your language
Run locale-gen command
Ensure locale alias with this command:
localedef -i es_ES -c -f UTF-8 -A /usr/share/locale/locale.alias es_ES.UTF-8
Set default Postgres lc_time value in /etc/postgresql/XX/main/postgresql.conf (By default is C.UTF-8, replace it using your language code alias)
Restart Postgres service
Test it in psql command interface
SELECT TO_CHAR('2022-01-01'::Date, 'TMmonth');