Re: Getting the Name of a month from an Int

From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 07/01/04


Date: Thu, 1 Jul 2004 16:00:28 +0200

Watch out if not in US:

set language british
declare @Month int
set @Month = 6

select
    datename (mm, convert (datetime, '2004/' + str (@Month) +'/01'))

-- 
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Tom Moreau" <tom@dont.spam.me.cips.ca> wrote in message
news:%23x9zU02XEHA.2840@TK2MSFTNGP11.phx.gbl...
> You could make a dummy date string, using the given month:
>
> declare @Month int
> set @Month = 6
>
> select
>     datename (mm, convert (datetime, '2004/' + str (@Month) +'/01'))
>
>
> -- 
>    Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON   Canada
> www.pinnaclepublishing.com/sql
> .
> "Peter Newman" <PeterNewman@discussions.microsoft.com> wrote in message
> news:3B41D482-787F-437E-A895-3A2BC05505EB@microsoft.com...
> I know how to get a MonthName  from a Date
>
> Declare @Name Varchar(15)
> Set @Name = DateName(Month, GetaDate())
>
> @Name would = July
>
> is it possible to get the same rewsult using an INT ?
>
> Declare @DesiredMonthName INT
>
> Set @DesiredMonthName 06
> SET @Name = ?????
>


Relevant Pages