Convert month name to month number in SQL Server

In T-SQL what is the best way to convert a month name into a number?

E.g:

'January' -> 1
'February' -> 2
'March' -> 3

Etc.

Are there any built in functions that can do this?

Answers


How about this?

select DATEPART(MM,'january 01 2011') -- returns 1
select DATEPART(MM,'march 01 2011')  -- returns 3
select DATEPART(MM,'august 01 2011') -- returns 8

Need Your Help

How do I merge rows from a select statement based on conditions

sql-server

Sorry for the vague description, but I'm not sure how to say this.

use Owin OAuth 2.0 in multi tenant site

c# forms-authentication asp.net-identity owin

I am currently using Owin 2.0 in my multi tenant CMS. I need a way to change the facebook app id and secret depending on the tenant.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.