1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Oracle database, date freturn

Discussion in 'SQL PL/SQL' started by keshav jain, Jul 18, 2014.

  1. keshav jain

    keshav jain Active Member

    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    80
    Hi All

    I have a table in which I have two columns i.e. YEAR and MONTH these are as
    year.......................month
    2012.......................5
    2012.......................6
    2012.......................8
    2012.......................9
    2012.......................10
    2014.......................5
    2014.......................6
    2014.......................1
    2014.......................2
    2014.......................3


    desire output
    date
    May,2012
    Jun,2012
    Aug,2012
    Sep,2012
    Oct,2012
    so on........
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    For a start give an example of creation of the table and a script of its filling

    See to links :
    to_date
    to_char
    Format Models

    Simple example :
    Code (SQL):
     SELECT to_char(to_date ('2012-5','YYYY-MM'),'MON,YYYY') FROM dual ;
     
  3. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Hi Keshav,

    Agree with Sergey, we'll be in a better position to provide you with the most accurate & fast solution if the post has all the relevant information.

    Anyway, let's assume your table name is "my_tab" and the columns are "xyr" and "xmon", then you just need to do:

    Code (SQL):
    SELECT  TO_CHAR(TO_DATE(xyr||xmon, 'YYYYMM'), 'Mon,YYYY') FROM my_tab;