Month/Year

  • Hi,

    I can't list just month and year - in only column - from a date columnn. When I try this

     SELECT     MONTH(DATE) & YEAR(DATE) AS MONTHYEAR FROM   TABLE   

    return all 0 in column. 

    Can you help me?

    thanks

    Mairim

  • SELECT CAST(MONTH(GETDATE()) AS VARCHAR(2)) + CAST(YEAR(GETDATE()) AS CHAR(4))



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • SELECT     MONTH(DATE) & YEAR(DATE) AS MONTHYEAR FROM   TABLE   

    & is performing a bitwise AND between the month and year outputs.

    In Sql Server you use + to concatenate values together, but you will need to convert those values to strings first, just like in A J's code in the post above.

     


    Julian Kuiters
    juliankuiters.id.au

  •   AJ

    Thank you, very much!!!

    Mairim

     

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

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