How can i just get month and date only in a queary without the year?

  • this is what i have for a query but i would like to take the year off. is there a way i can just have the month and day without the year attached?

  • You can use datepart to extract the month, and day, and then concatenate them together.

    cast( datepart(mm, mydatecolumn) as char(2)) + '/' + cast( datepart(dd, mydatecolumn) as char(2))

  • Steve Jones - SSC Editor (3/18/2015)


    You can use datepart to extract the month, and day, and then concatenate them together.

    cast( datepart(mm, mydatecolumn) as char(2)) + '/' + cast( datepart(dd, mydatecolumn) as char(2))

    Alternatively

    select convert(char(5), mydatecolumn,101)


  • Thanks it worked like a charm 🙂

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

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