Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Get Month Name Rate Topic Display Mode Topic Options
Author
 Message
 Posted Thursday, March 12, 2009 6:55 PM
 SSC-Forever Group: General Forum Members Last Login: Today @ 3:23 PM Points: 42,067, Visits: 39,449
 karthikeyan (3/12/2009)A little modification in Jeff's code.SELECT DateName(mm,DATEADD(mm,MonthNumber,-1))Yep... good call. --Jeff Moden"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".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." Helpful Links:How to post code problemsHow to post performance problems
Post #674873
 Posted Monday, January 18, 2010 2:36 AM
 Forum Newbie Group: General Forum Members Last Login: Tuesday, July 27, 2010 3:09 AM Points: 1, Visits: 28
 Super Logic..Keep Rocking:)
Post #849025
 Posted Monday, March 29, 2010 2:43 AM
 Grasshopper Group: General Forum Members Last Login: Saturday, June 12, 2010 9:31 AM Points: 12, Visits: 14
 Here is one line solution in my implementation.http://praveenbattula.blogspot.com/2009/04/how-to-know-month-name-from-month-index.html
Post #891657
 Posted Friday, April 2, 2010 6:11 PM
 SSC-Forever Group: General Forum Members Last Login: Today @ 3:23 PM Points: 42,067, Visits: 39,449
 The character conversion will slow things down quite a bit if you happen to use the for batch programming on millions of rows. --Jeff Moden"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".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." Helpful Links:How to post code problemsHow to post performance problems
Post #896086
 Posted Wednesday, April 7, 2010 10:49 PM
 SSCommitted Group: General Forum Members Last Login: Tuesday, August 2, 2016 2:14 PM Points: 1,519, Visits: 4,107
  Ack, thought I had scrolled down all the way, apparently I was wrong.Since I've posted anyways, might as well mention that doing it this way automatically adjusts for language settings.`set language spanishselect DATENAME(m,DATEADD(m,1,-1))--Eneroselect DATENAME(m,DATEADD(m,2,-1))--Febreroselect DATENAME(m,DATEADD(m,3,-1))--Marzoselect DATENAME(m,DATEADD(m,4,-1))--Abril` Seth PhelabaumConsistency is only a virtue if you're not a screwup. Links: How to Post Sample Data :: Running Totals :: Tally Table :: Cross Tabs/Pivots :: String Concatenation
Post #899272
 Posted Tuesday, April 20, 2010 1:41 PM
 SSC Veteran Group: General Forum Members Last Login: Saturday, October 8, 2016 1:59 PM Points: 263, Visits: 559
 Gailyou rock!but you knew that alreadythis also works in SQL Server 2000
Post #907206
 Posted Friday, May 21, 2010 12:55 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Thursday, May 2, 2013 1:50 AM Points: 167, Visits: 37
 Similarly if you want to list all the month names for a year using a T-SQL statement, you can do this:SELECT Number + 1 as [MonthNumber],DateName(mm,DATEADD(mm,Number,0)) as [MonthName]FROM master..spt_valuesWHERE Type = 'P' and Number < 12
Post #925702
 Posted Sunday, June 6, 2010 6:58 PM
 SSC-Enthusiastic Group: General Forum Members Last Login: Sunday, April 15, 2012 7:06 AM Points: 122, Visits: 205
 drop table sample_tablecreate table sample_table (id int, dat datetime)insert into sample_table values(1,getdate())select * from sample_tableselect id,dat from sample_table where datename(month,dat)='June'----------------------------------------- id dat----------------------------------------- 1 2010-06-07 10:54:52.607-----------------------------------------Cheers,Venkatesan Prabu .Jhttp://venkattechnicalblog.blogspot.com/ Thanks and Regards,Venkatesan Prabu, :PMy Blog: http://venkattechnicalblog.blogspot.com/
Post #933306
 Posted Sunday, June 6, 2010 9:28 PM
 SSC-Forever Group: General Forum Members Last Login: Today @ 3:23 PM Points: 42,067, Visits: 39,449
 Venkatesan Prabu (6/6/2010)drop table sample_tablecreate table sample_table (id int, dat datetime)insert into sample_table values(1,getdate())select * from sample_tableselect id,dat from sample_table where datename(month,dat)='June'----------------------------------------- id dat----------------------------------------- 1 2010-06-07 10:54:52.607-----------------------------------------Cheers,Venkatesan Prabu .Jhttp://venkattechnicalblog.blogspot.com/Ummm... I don't get it. How does that deal with the original request of converting month numbers to month names? --Jeff Moden"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".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." Helpful Links:How to post code problemsHow to post performance problems
Post #933320
 Posted Saturday, June 12, 2010 9:07 AM
 Forum Newbie Group: General Forum Members Last Login: Friday, March 13, 2015 4:22 PM Points: 8, Visits: 58
 Awesome, thanks so much to Jeff and Karthik!I want to say thank you to Jeff for helping so many of us, Much appreciated!
Post #936441

 Permissions