data function

  • Hi All

    In Sql Server Db2005

    record is like give below

    Column-YearMonthNumber of dayHospital Name Address

    Value-20101212 Ramana Hospital test test test

    In UI month value is display as December

    I have to write query for this Month value instead of 12 i have to display December

    pls advice me with query.

  • This is the least flexible way to do it:

    case month when 1 then 'January'

    when 2 then 'February'

    when 3 then 'March' --etc

    end MonthName

  • Hi ,

    thanks for reply

    i wrote the query

    i used dateadd funciton

    DateAdd( month , @Monthnumber, 0 ) - 1 )

    Regards,

    firoz

  • As a side bar, storing dates as separate columns for Year, Month, and Day normally creates more problems than it's worth especially when it comes to future aggregations for reporting. My recommendation would be to store the date as a full DATETIME and have persisted calculated columns that separate the date into Year, Month, and Day if you really need them for reporting purposes.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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