Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Month Names

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-11 : 11:22:33
arun writes "Looking for sql query which will return months (i.e need 12 rows with month name each).

ex: Jan
Feb
Mar...."

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-11 : 11:25:35
use datename(month, @date)


KH

Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-07-11 : 11:33:12
select shortmonths from master.dbo.syslanguages where name = 'us_english'

select distinct number, datename(month, dateadd(month, number, -1)) as Month,
left(datename(month, dateadd(month, number, -1)), 3) as ShortMonth
from master.dbo.spt_values where number between 1 and 12

/*
shortmonths
-------------------------------------------------------
Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec

number Month ShortMonth
----------- ------------------------------ ----------
1 January Jan
2 February Feb
3 March Mar
4 April Apr
5 May May
6 June Jun
7 July Jul
8 August Aug
9 September Sep
10 October Oct
11 November Nov
12 December Dec
*/


Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -