Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
SQL Server Newbies
»
Get Month Name
28 posts, Page 1 of 3
1
2
3
»
»»
Get Month Name
Rate Topic
Display Mode
Topic Options
Author
Message
Shakti Singh Dulawat
Shakti Singh Dulawat
Posted Friday, February 08, 2008 12:23 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 15, 2012 4:29 PM
Points: 19,
Visits: 76
Hi all
Is there any best way to get month name in SQL SERVER 2005.
I know that we can do this using our own function, but just i want to conform that if SQL SERVER provide any function for month name if we have month number i.e. 1,2..12
Thanks
Warm Regards,
Shakti Singh Dulawat
Before printing, think about the environment
Do the impossible, and go home early.
Post #453088
GilaMonster
GilaMonster
Posted Friday, February 08, 2008 1:30 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:18 PM
Points: 37,744,
Visits: 30,025
SQL has a DateName function, however it takes a datetime as a parameter, not a number
SELECT DATENAME(month, GETDATE()) AS 'Month Name'
returns
Month Name
------------------------------
February
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #453098
Shakti Singh Dulawat
Shakti Singh Dulawat
Posted Friday, February 08, 2008 1:45 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 15, 2012 4:29 PM
Points: 19,
Visits: 76
Thanks
Thats good
But is there is way so we can get month name using month number.
Warm Regards,
Shakti Singh Dulawat
Before printing, think about the environment
Do the impossible, and go home early.
Post #453100
GilaMonster
GilaMonster
Posted Friday, February 08, 2008 1:52 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:18 PM
Points: 37,744,
Visits: 30,025
Not directly, though you could convert the month number inot a date.
SELECT DATENAME(month,'1900/' + CAST(monthNumber AS VARCHAR(2)) + '/01')
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #453101
Shakti Singh Dulawat
Shakti Singh Dulawat
Posted Friday, February 08, 2008 10:36 PM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 15, 2012 4:29 PM
Points: 19,
Visits: 76
Thanks very much
Warm Regards,
Shakti Singh Dulawat
Before printing, think about the environment
Do the impossible, and go home early.
Post #453558
raju.msoftprof
raju.msoftprof
Posted Tuesday, March 11, 2008 8:50 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, June 02, 2009 4:42 AM
Points: 1,
Visits: 23
thank you GilaMonster...
Post #467475
Jeff Moden
Jeff Moden
Posted Tuesday, March 11, 2008 9:15 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 6:25 PM
Points: 32,930,
Visits: 26,819
GilaMonster (2/8/2008)
Not directly, though you could convert the month number inot a date.
SELECT DATENAME(month,'1900/' + CAST(monthNumber AS VARCHAR(2)) + '/01')
Heh, too much VARCHAR in that for me, Gail... :P
SELECT DATENAME(mm,DATEADD(mm, MonthNumber-1,0))
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #467495
vikrammstein
vikrammstein
Posted Wednesday, March 11, 2009 6:50 AM
Forum Newbie
Group: General Forum Members
Last Login: Monday, April 06, 2009 9:52 PM
Points: 1,
Visits: 6
thanks a ton.....
it helped. :D
Post #673192
Jeff Moden
Jeff Moden
Posted Wednesday, March 11, 2009 9:33 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 6:25 PM
Points: 32,930,
Visits: 26,819
You bet... thanks for the feedback.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #673916
karthik M
karthik M
Posted Thursday, March 12, 2009 3:30 AM
SSCrazy
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 2:56 AM
Points: 2,008,
Visits: 2,469
A little modification in Jeff's code.
SELECT DateName(mm,DATEADD(mm,MonthNumber,-1))
karthik
Post #674030
« Prev Topic
|
Next Topic »
28 posts, Page 1 of 3
1
2
3
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.