Coverting decimal to a date value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhavya Mano
    New Member
    • Mar 2011
    • 1

    #1

    Coverting decimal to a date value

    hi
    I have a table with a date column set as decimal type, another thing is that they have have entered an extra 1 in front of each value due to the Y2K problem, example for 2010 jan it shows 11001 is there any way for me to convert this so that the data shows as either 2010 Jan or as jan-10 or as 01-10 either one of this would good.

    thank you

    bhavya
  • gpl
    New Member
    • Jul 2007
    • 152

    #2
    The simple way would be to convert it to a string and pull out the relevant parts with substring, eg
    Code:
    select 
    substring(convert(varchar(5),mydate, 1,2) + '-' + 
    substring(convert(varchar(5),mydate, 4,2) as ThisDate
    from {table}

    Comment

    Working...