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.
- Kategorie
- Dates & times
- Returns
session variable- In this category
- 97 of 121
Syntax
SET lc_time_names = 'de_DE'
Engine-Unterstützung
| Engine | Support | Notizen |
|---|---|---|
| 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 | Ja | 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 |
Beispiele
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
Gut zu wissen
- 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.
Related on SQLly
Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, Oracle.
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.