0

I have a bar chart as below enter image description here

the horizontal axis has months and years,is there any way i can sort the months order? like January,february,March...

thanks in advance

SqlLearner
  • 763
  • 8
  • 23
  • 37

2 Answers2

0

Sort by the month number but display the month name:

SELECT Month(DateField) AS [Month], DateName(Month, DateField) AS [MonthName], OtherFields
FROM MyTable
ORDER BY Month(DateField)
Chris Latta
  • 20,316
  • 4
  • 62
  • 70
0

you can use this DATEPART(m, table.date) AS MonthNumber, and you can sort it using this field, and add more sort field on the top for years using this DATEPART(yyyy, table.date) AS AccountYear.

Hani Adel
  • 3
  • 5