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)

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Thanks it worked like a charm 🙂

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

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