Saturday, May 16, 2015

Sql Server order by month name


Following Script will order the result in actual calendar month order.

SELECT *  FROM [dbo].[tablename]
ORDER BY DATEPART(mm,CAST([DateFieldColumnName] + ' 1900' AS DATETIME)) ASC

No comments: