Year-month format, how to?

  • Hi there,

    I like to get the year and month from a given date in the format yyyymm. I can do this fine, but months 1 tru 9 are represented as singlen digits, while I want them as 200501, 200502 etc.

    I think I can do that as well, but it takes some doing, and maybe someone has made a function like this already. Googled the Net, could not find a solution.

    Anyone can help me out?

    Greetz,
    Hans Brouwer

  • use the Convert function:

    select convert( char(6), getdate(), 112)

    Cheers,

     


    * Noel

  • That simple, huh? I was thinking about trailing blanks changing into zero...

    Tnx, Noeld

    Greetz,
    Hans Brouwer

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

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