Months in Ascending order

  • My Problem is that , i have to show months in Ascending order. How will i do this task. is there any function which show Months in ASCending order????

  • Have a look at BOl and use the

    SELECT DATENAME(month, getdate()) AS 'Month Name'
    This retrurns the Name of the month, you might have to fine tune it to select a DISTINCT and the order by.
     
    Hope this helps...
     

    Hope this helps...

    Ford Fairlane
    Rock and Roll Detective

  • Convert your month to an integer between 1 and 12 (1 = Jan, 2 = Feb etc) using datepart and then use that in your ORDER BY clause:

    select datefield

    order by datepart(m, datefield)

    Regards

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • I would create either a reference table consisting of Month# and Month Name then link that into your query for your order clause, or perhaps do it through a UDF. I'm not sure which would perform more efficiently.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply