convert month name to month number

  • Very forgiving indeed.

    SELECT MONTH('April' + ' 1900')


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • madhu.gut - Thursday, May 6, 2010 1:34 AM

    Hi AllHow should i convert the month name to month number like'April' it should converted to 4'January' it should converted to 1in this how should i do thiscan any one suggest the correct answer

  • SELECT DATEPART(MM,'january '+'01 1900')
    SELECT MONTH('january ' + '01 1900')
    SELECT month(dateadd(month,DATEDIFF(month,0,'january 01 2015'),0))

  • This was removed by the editor as SPAM

Viewing 4 posts - 16 through 18 (of 18 total)

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