Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    35

    Unanswered: Convert dd-mmm-yyyy to mmm-yyyy

    In Orcale how can I convert date in 'dd-mmm-yyyy' format to 'mmm-yyyy' format?

    Thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,296
    do you mean 01-Jun-1984 to Jun-1984?

    select to_char(date_column,'Mon-YYYY') from table_name;

    PHP Code:
    integration@kod1select sysdate from dual;

    SYSDATE
    ---------
    08-MAR-04

    integration
    @kod1select to_char(sysdate,'Mon-YYYY'from dual;

    TO_CHAR(
    --------
    Mar-2004 
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Convert dd-mmm-yyyy to mmm-yyyy

    Oracle dates are not stored in any particular format. To convert a date value to a string in the format 'mon-yyyy' use TO_CHAR(date_value,'MON-YYYY'). To convert a string in the format 'dd-mon-yyyy' to a date use TO_DATE(string_value,'DD-MON-YYYY').

    To convert a string from 'dd-mon-yyyy' format to another string in 'mon-yyyy' format combine the two operations like this:

    TO_CHAR( TO_DATE( string_value, 'DD-MON-YYYY'), 'MON-YYYY' )

Posting Permissions

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