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
 SQL Server Development (2000)
 Get month name from number

Author  Topic 

Filia
Starting Member

3 Posts

Posted - 2004-10-21 : 04:17:31
Hi,

This could be a stupid question so prepare yourselves...
Is there a way that I can get a month name to be returned by submitting an integer value?

Eg:
declare @intMonthNo int,
select @intMonthNo = 10

How do I get the value 'October' from SQL? When I use
DATENAME(m, @intMonthNo) the month returned is 'January'!!!

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-10-21 : 04:31:37
since it's an int, i just added the missing date part, day and year...

select datename(month,convert(datetime,convert(varchar(2),@int)+ '/01/2004'))



--------------------
keeping it simple...
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-21 : 04:45:57
select datename(month, dateadd(mm,@val,'19000101'))


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -