Brettb.Com
  HOME | ABOUT ME | BIOTECHNOLOGY | ARTICLES | GALLERY | CONTACT
Search: Go
TECHNICAL ARTICLES
 ASP
 ASP.NET
 JavaScript
 Transact SQL
 Other Articles
 Software Reviews

PHOTO GALLERIES
 Canon EOS 300D Samples
 Akihabara Maids!
 More Galleries...

TRAVEL LOG
 2009: China
 2008: Tokyo
 2007: Tokyo
 2006: Hong Kong
 2005: New York City

MORE STUFF
 Search Engine Optimisation
 Build an ASP Search Engine
 My Tropical Fishtank
 Autoglass
 SQL Month Name
 SQL Get Date Today
 SQL Year Month
 Other New Stuff...

POPULAR STUFF
 Regular Expressions
 Index Server & ASP
 JavaScript Ad Rotator

Home > Articles > Transact SQL Programming Articles

SQL Server Help: How to find the month name in Transact-SQL

The SQL GetDate() function can be used to return the current date in SQL. There is also a Month function that will return the numerical value of the DateTime variable's month value:

SELECT MONTH(GetDate()) as 'month'

For Month, January = 1 and December = 12.

To get the month name you need to use the SQL DateName function. This takes two arguments, the part of the date you want and the DateTime variable. The SQL statement below shows the current month name:

SELECT DateName(m, GetDate()) AS 'month'

The month name is returned as a nvarchar data type. This also works for retrieving the current month name:

SELECT DateName(mm, GetDate()) AS 'month'

Useful Links

  • The SQL Documentation Tool builds technical documentation for Microsoft SQL Server databases. A free trial version is available for download.

  Site Map | Privacy Policy

All content is 1995 - 2012