• madhu.gut (5/6/2010)


    Hi All

    How should i convert the month name to month number like

    'April' it should converted to 4

    'January' it should converted to 1

    in this how should i do this

    can any one suggest the correct answer

    There've been a lot of answers to this question and they could all be unnecessary because SQL Server is very forgiving for most date formats. With that thought in mind, what does the original data look like? And I'm not just talking about the month name. For example, if your trying to convert a string to an SQL Datetime and the date looks like '1 June 2010', there you don't need to find the month number to do the conversion....

    SELECT CAST('4 June 2010' AS DATETIME)

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)