Display Month Name in SQL Server in Different Languages

Languages are a significant part of human history, culture, and communication and different languages offer unique insights into diverse worldviews and traditions. The following are ten of the most widely spoken languages around the world. Each language is accompanied by a T-SQL code snippet that formats a date to display the month name in that specific language.

So, let’s break down the T-SQL code by language with a short description for each language. In a previous article we saw how to display the month name using different T-SQL variations, without changing the language.

1. Display month name using SQL Server in Chinese (Mandarin)

Chinese is the official language of China and also Taiwan. Displaying month names in Chinese (Mandarin) within SQL Server requires an understanding of its linguistic nuances. Mandarin Chinese, serving as the official language of both China and Taiwan, holds significant global importance.

In SQL Server, formatting dates to display month names in Mandarin involves utilizing language-specific functions and character sets, ensuring accurate representation within database systems.

DECLARE @date datetime = '2023-01-01';
SELECT FORMAT(@date, 'MMMM', 'zh-CN') AS 'zh-CN'; -- Chinese (Mandarin)

Explanation of the query:

  • Within the SELECT statement, the FORMAT function is utilized to format the date stored in the @date variable.
  • The second parameter, ‘MMMM’, specifies the format of the output, indicating the full name of the month.
  • Third parameter is ‘zh-CN’, represents the culture or language for formatting, specifically Chinese (Mandarin) spoken in China.
  • The AS ‘zh-CN’ part assigns the resulting formatted month name to the column name ‘zh-CN’ in the output.

2. Spanish

The Spanish language is spoken in many countries, especially in Latin America and Spain.

DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'es-ES') AS 'es-ES'; -- Spanish
Queries To Display Month Name in SQL Server in Top 10 Languages
Queries To Display Month Name in SQL Server in Top 10 Languages

3. Display the month name in English using T-SQL

English is often described as a global lingua franca. This query is an example of how to display the name of the month in English (American) using SQL Server. By declaring a datetime variable and then utilizing the FORMAT function with the appropriate language code (‘en-US’), the query outputs the month name in English, specifically in the American format.

DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'en-US') AS 'en-US'; -- English American

4. Hindi

  • Description: Predominantly spoken in India.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'hi-IN') AS 'hi-IN'; -- Hindi

5. Month name in Arabic using T-SQL

  • Description: Official language in 26 countries in the Middle East and Africa.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'ar-SA') AS 'ar-SA'; -- Arabic

6. Portuguese

  • Description: Official language of Brazil and Portugal.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'pt-BR') AS 'pt-BR'; -- Portuguese (Brazil)

7. Bengali

  • Description: Official language in Bangladesh and parts of India.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'bn-BD') AS 'bn-BD'; -- Bengali (Bangladesh)

8. Russian

  • Description: Official language of Russia.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'ru-RU') AS 'ru-RU'; -- Russian

9. Japanese

  • Description: Official language of Japan.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'ja-JP') AS 'ja-JP'; -- Japanese

10. Month name in Lahnda (Western Punjabi)

  • Description: Spoken primarily in the Punjab region of Pakistan.
DECLARE @date datetime = '2023-01-01';

SELECT FORMAT(@date, 'MMMM', 'pa-PK') AS 'pa-PK'; -- Punjabi (Pakistan)

11. T-SQL query to get the month name in multiple languages at once

The code below, still uses the SQL Server’s FORMAT() function to extract the month name from a given date, here it is 2023-12-31. It generates a result set that displays the month’s name for this date across multiple prominent languages, such as Chinese (Mandarin), Spanish, English, and several others, all within a single query.

-- ** Code by Expert-Only.com ** --
DECLARE @date datetime = '2023-12-31';

    FORMAT(@date, 'MMMM', 'zh-CN') AS 'zh-CN',  -- Chinese (Mandarin)
    FORMAT(@date, 'MMMM', 'es-ES') AS 'es-ES',  -- Spanish
    FORMAT(@date, 'MMMM', 'en-US') AS 'en-US',  -- English American
    FORMAT(@date, 'MMMM', 'hi-IN') AS 'hi-IN',  -- Hindi
    FORMAT(@date, 'MMMM', 'ar-SA') AS 'ar-SA',  -- Arabic
    FORMAT(@date, 'MMMM', 'pt-BR') AS 'pt-BR',  -- Portuguese (Brazil)
    FORMAT(@date, 'MMMM', 'bn-BD') AS 'bn-BD',  -- Bengali (Bangladesh)
    FORMAT(@date, 'MMMM', 'ru-RU') AS 'ru-RU',  -- Russian
    FORMAT(@date, 'MMMM', 'ja-JP') AS 'ja-JP',  -- Japanese
    FORMAT(@date, 'MMMM', 'pa-PK') AS 'pa-PK';  -- Punjabi (Pakistan);

The result gives this result in SSMS:

十二月diciembreDecemberदिसम्बरجمادى الثانيةdezembroডিসেম্বরДекабрь12月ਦਸੰਬਰ
Month translated in the World top 10 languages using FORMAT and ISO country codes

Note the specificities for Arabic, the month name “جمادى الثانية” is not December in Arabic; it refers to a month in the Islamic lunar calendar. And in the Gregorian calendar, December is represented as “ديسمبر” in Arabic.

SQL Server and Multilingual Month Display challenges

In summary, this article explains the SQL Server functionality to display month name in the top 10 languages globally most spoken. Through the examination of language-specific T-SQL code snippets, we’ve highlighted the platform’s capability to accommodate diverse linguistic needs. This analysis emphasizes the practical importance of language support within database systems, facilitating efficient data management in multilingual environments.

Be the first to comment

Leave a Reply

Your email address will not be published.