Home Forums SQL Server 2008 T-SQL (SS2K8) How to order date which month is in abbreviation format RE: How to order date which month is in abbreviation format

  • SELECTDate_Month

    , LEFT(Date_Month,3) AS Mo3

    , CAST(RIGHT(Date_Month,4) AS INT) AS Yr

    , CAST(LEFT(Date_Month,3) + ' 1, ' + RIGHT(Date_Month,4) AS DATE) AS DateFun

    FROM (

    SELECT 'APR 2012' AS Date_Month

    UNION ALL

    SELECT 'JAN 2012'

    UNION ALL

    SELECT 'AUG 2012'

    UNION ALL

    SELECT 'AUG 2013'

    UNION ALL

    SELECT 'DEC 2012') x

    ORDER BY DateFun DESC;