How to Display DateTime Formats in Different Languages using SQL Server

SET LANGUAGE can be used to specify the language environment for the current session. You can use the sys.syslanguages to first determine the languages present in an instance of SQL Server

SELECT * FROM sys.syslanguages

image

Once you know the different languages, use SET LANGUAGE to display the DateTime in the language you desire as shown below. You can specify either the alias of the language (Spanish, German) or the name(us_english) as the argument. The query shown below displays the Day Name in different languages:

SET LANGUAGE Spanish
SELECT DATENAME(dw, GETDATE()) AS 'DayName'

SET LANGUAGE German
SELECT DATENAME(dw, GETDATE()) AS 'DayName'

SET LANGUAGE us_english
SELECT DATENAME(dw, GETDATE()) AS 'DayName'
GO

OUTPUT

image


About The Author

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigous Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook

1 comment:

mihai's user said...

thanks! help me a lot!