Month name using query

  • Can anyone help me out with a query that will give u the monthname like if i tell 1 then jan should be returned.

    A query should give me this result.

    Thanks

  • hi, check out the datename function in BOL :-

    select datename(month,1)

    returns January and so on, just change the number ...

    HTH

    Paul

  • Whatever month number is given it always returns only january

  • quote:


    select datename(month,1)


    there is a little typo is the above

    the second parameter specifies from which date the monthname will be extracted

    select datename(month,getdate())

    ------------------------------

    September

    (1 row(s) affected)

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • What is happening in the first example is using a number like 1 is considered the number of days since 1/1/1970 so 1 is 1/2/1970 and 12 is 1/13/1970, all of which are January.

  • Thank you. I was able to achieve the result i wanted with this clue

  • You might also want to check out the 'datepart' command

Viewing 7 posts - 1 through 6 (of 6 total)

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