// dates & times reference

SQL lc_time_names variable

A session variable selecting the language MySQL uses for month and day names in formatted output: 'de_DE', 'ja_JP', 'fr_FR' and so on.

Categoria
Dates & times
Returns
session variable
In this category
97 of 121

Sintaxe

SET lc_time_names = 'de_DE'

Suporte a mecanismos

MotorSupportNotas
SQL Server Different name or syntax SET LANGUAGE: changes DATENAME output and date parsing order
PostgreSQL Different name or syntax lc_time setting plus the TM prefix in to_char
MySQL Sim Supported under this name.
SQLite Not built in names are not produced at all
Oracle Different name or syntax NLS_DATE_LANGUAGE per session or per TO_CHAR call

Exemplos

MySQL

SET lc_time_names = 'fr_FR';  SELECT DATE_FORMAT('2026-08-01', '%W %d %M');  -- samedi 01 août

Oracle

SELECT TO_CHAR(DATE '2026-08-01', 'DD Month', 'NLS_DATE_LANGUAGE=FRENCH') FROM dual;  -- 01 Août

Bom saber

  • lc_time_names changes %W, %a, %M and %b in DATE_FORMAT, plus DAYNAME and MONTHNAME. It does not touch STR_TO_DATE, which parses English names only: STR_TO_DATE('1 Juli 2026', '%d %M %Y') is NULL even on a de_DE session.
  • Locale names use an underscore: 'de_DE', not 'de-DE'. An unknown name fails with error 1649 (Unknown locale) instead of falling back to English.
  • Per-call overrides beat session changes for mixed-locale reports: Oracle TO_CHAR(d, 'DD Month', 'NLS_DATE_LANGUAGE=FRENCH'). PostgreSQL's to_char(d, 'DD TMMonth') follows the lc_time setting, which SET can change per session.
  • %p is not localized: DATE_FORMAT(d, '%p') prints AM or PM under fr_FR too.

Questions about lc_time_names

Does lc_time_names change how dates are stored?

No. Stored values never localize. It changes formatted output only; STR_TO_DATE keeps parsing English names.

How do I localize dates in SQL Server?

SET LANGUAGE (affects DATENAME) or FORMAT(d, 'MMMM', 'de-DE') with an explicit culture; FORMAT is the per-call option that does not leak session-wide.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.