Full List of Locales in MySQL

This post contains a full list of locales supported by MySQL 8.0 that can be used as a value for the lc_time_names system variable. This locale controls the language used to display day and month names and abbreviations.

The following table lists these locale values, along with the language and region. These may be different to those supported by your operating system.

To set the locale, see How to Set the Locale for the Current Connection in MySQL.

Read more

How to Set the Locale for the Current Connection in MySQL

There are certain date functions in MySQL that the return a day name or month name. In particular, I’m referring to the DATE_FORMAT(), DAYNAME(), and MONTHNAME() functions. These might return a value of say, November, or Monday, depending on the query being used. But the results could just as easily be returned in a different language if required.

The language that these functions use for their return value is derived from the lc_time_names system variable. You can view the value of this variable or set its SESSION value so that the results of these functions is in the desired language/locale.

Locale names have language and region subtags listed by the Internet Assigned Numbers Authority (IANA). Examples include en_US for English – United States, en_NZ for English – New Zealand, or es_PA for Spanish – Panama, etc (for a list of locales supported by MySQL, see Full List of Locales in MySQL).

In this article, I’ll show you how to find the current locale for your connection, change it, and then see how it affects the results of a query. I also show you a function that’s immune to this setting (but don’t worry, this function allows you to specify the locale).

Read more

MONTH() Examples – MySQL

You can use the MONTH() function in MySQL to return the month from a date.

In this context, the month is a value between 1 and 12 (or 0 for dates with a zero month part).

For example, if you provide a date of 2018-10-07, the MONTH() function will return 10.

Read more

MAKETIME() Examples – MySQL

When using MySQL, you can use the MAKETIME() function to return a time from the various time parts.

In other words, you provide three arguments; the hour, the minutes, and the seconds. The MAKETIME() function will then return the time value based on those two arguments.

Read more

MAKEDATE() Examples – MySQL

When using MySQL, you can use the MAKEDATE() function to return a date from the year and day-of-year parts.

In other words, you provide two arguments; one being the year, and the other being the day-of-year. The MAKEDATE() function will then return the date value based on those two arguments.

Read more