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 2008 Forums
 Transact-SQL (2008)
 Month Name order monthwise

Author  Topic 

zara_chd
Starting Member

7 Posts

Posted - 2011-10-04 : 12:37:17
Hi all,

Is there any way I can order month names monthwise,I have used MonthName function to get the names of the month. But all month names are coming in alphabatical order. I want all month names in monthwise e.g. dec,jan feb,march april etc.

Please some one help me
Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-04 : 12:39:20
ORDER BY DATEPART(mm,DateField)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-10-05 : 01:02:13
SELECT DATENAME(MONTH, Col1), SUM(Col2)
FROM dbo.Table1
GROUP BY DATENAME(MONTH, Col1), DATEPART(MONTH, Col1)
ORDER BY DATEPART(MONTH, Col1)



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

zara_chd
Starting Member

7 Posts

Posted - 2011-10-05 : 07:18:52
quote:
Originally posted by visakh16

ORDER BY DATEPART(mm,DateField)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Thankssss, it worked
Go to Top of Page

zara_chd
Starting Member

7 Posts

Posted - 2011-10-05 : 07:19:26
quote:
Originally posted by SwePeso

SELECT DATENAME(MONTH, Col1), SUM(Col2)
FROM dbo.Table1
GROUP BY DATENAME(MONTH, Col1), DATEPART(MONTH, Col1)
ORDER BY DATEPART(MONTH, Col1)
THANKS DEAR


N 56°04'39.26"
E 12°55'05.63"


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-05 : 07:39:19
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -