Archive

Posts Tagged ‘month name in sql’

Set Language in Sql Server

When  you are working with multi lingual web applications, you may need to retrieve data like month name, day name etc to be displayed in different languages. For example month “June” is in English, its dutch translation would be “Juni” .This is possible with “Set Language languagname” feature of sql server. where language name is the name of language you want to set.. you can complete list of languages that sql support using

select * from sys.syslanguages

Below is one example using set language, retrieving day and month name in different languages:
DECLARE @Today DATETIME
SET @Today = ‘6/22/2009’

SET LANGUAGE Deutsch
SELECT DATENAME(month, @Today) AS ‘Month Name in Dutch’
SELECT DATENAME(dw, @Today) AS ‘Day Name in Dutch’

SET LANGUAGE us_english
SELECT DATENAME(month, @Today) AS ‘Month Name in English’
SELECT DATENAME(dw, @Today) AS ‘Day Name in English’