Convert integer value of date to equivalent month (1=Jan, 2=Feb....)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sumaiya Patel

    Convert integer value of date to equivalent month (1=Jan, 2=Feb....)

    i have a table Month which contains two columns month(type integer) and closed_mon(type bit).
    column month contains values such as 201004,201005.. .. where 2010 is year and 04 is the month (yyyymm format).
    I want to exact this field and convert it to its equivalent month and vice-versa. Ex. 201004 should appear as April 2010.

    Please Help..!!
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Use STR_TO_DATE and DATE_FORMAT functions in the following manner
    [CODE=mysql]SELECT DATE_FORMAT(STR _TO_DATE('20100 4','%Y%m'), '%M %Y');[/CODE]

    Comment

    • Sumaiya Patel

      #3
      Thanks for your reply... but i am using sybase and it is giving error with STR_TO_DATE function

      Comment

      Working...