Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Convert Months,Days,ShortMonths to different Languages

By William McLaughlin,

This script allows you to convert date languages without exsplicitly setting the language in sql server it can be used in views,storedprocedures and select statements

/**
examples
 posible input values Months,Days,ShortMonths
 Returns all values for the language selected
 select * from dbo.FN_ConvertLanguageValues('Dutch','Months')
 select * from dbo.FN_ConvertLanguageValues('Dutch','Days')
 select * from dbo.FN_ConvertLanguageValues('Dutch','ShortMonths')

'Direct query example returns current month for current date
select item as dutchmonth from dbo.FN_ConvertLanguageValues('Dutch','months') where row = DATEPART(m, getdate())
 
 'Select the dayname for the current day
 select item as dutchday from dbo.FN_ConvertLanguageValues('Dutch','days') where row = DATEPART(weekday, getdate())

 'Table Query Examples
  select myfield,(select item as dutchmonth from dbo.FN_ConvertLanguageValues('Dutch','months') where row = DATEPART(m, mydatefield)) as dutchmonth from mytable
  select myfield,(select item as dutchday from dbo.FN_ConvertLanguageValues('Dutch','days') where row = DATEPART(weekday, mydatefield)) as dutchday from mytable

 Helper Functions

--Example select the day name for the given date

--select dbo.dayNames('Dutch',GetDATE()) as dayname

--Example Select the MonthName for the Given Date

--select dbo.monthNames('Dutch',GetDATE()) as monthname

 -- additional example

Select dbo.daynames('dutch',GetDate()) + ' ' + convert(varchar,Datepart(day,getdate())) + ' ' + dbo.monthnames('dutch',getdate()) + ' ' + convert(varchar(4),year(getdate()))

Total article views: 819 | Views in the last 30 days: 50
 
Related Articles
FORUM

select from GETDATE()?

select from GETDATE()?

FORUM

select 21/(datediff(dd,getdate(),getdate())

select 21/(datediff(dd,getdate(),getdate())

FORUM

GetDate Function

Getdate() as default

FORUM

Issue with trying to incorporate the following SELECT DATEPART(WEEKDAY, GETDATE())

Issue with trying to incorporate the following SELECT DATEPART(WEEKDAY, GETDATE())

FORUM

help using getdate function

help using getdate function

Tags
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones