Results 1 to 5 of 5

Thread: rename a column

  1. #1
    Join Date
    Mar 2004
    Posts
    14

    Unanswered: rename a column

    hi, I tried to rename a column to Month using :

    select to_char(sysdate 'MM') "Month" from dual;

    but the output only list two characters"Mo" instead of Month.

    MO
    ----
    03

    Any one knows why this happened and how to rename it? thanks!

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    Hi,
    select to_char(sysdate ,'MM') AS Month from dual
    The above query only displays two digit for month. Therefore oracle truncate the alias(renaming column) to two digit i.e "Mo".

    Look at the result for the below query. It displays full alias

    SQL> select to_char(sysdate ,'DD-MM-YYYY') AS Month from dual;
    MONTH
    ----------
    18-03-2004


    Thanks,
    Pagnint
    (No need to search web before posting new question)

  3. #3
    Join Date
    Mar 2004
    Posts
    14
    thanks, but I need the month only, not year and day.

    Originally posted by paginit
    Hi,
    select to_char(sysdate ,'MM') AS Month from dual
    The above query only displays two digit for month. Therefore oracle truncate the alias(renaming column) to two digit i.e "Mo".

    Look at the result for the below query. It displays full alias

    SQL> select to_char(sysdate ,'DD-MM-YYYY') AS Month from dual;
    MONTH
    ----------
    18-03-2004


    Thanks,

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    Can u please tell . Why you need month. I Mean functional requirment


    Thanks
    Pagnint
    (No need to search web before posting new question)

  5. #5
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    Try with this

    SQL> column Month format a6;
    SQL> select to_char(sysdate, 'MM') "Month" from dual;

    Month
    ------
    03

    Thanks,
    Pagnint
    (No need to search web before posting new question)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •