How to display date in a different format in oracle

前端 未结 4 1255
萌比男神i
萌比男神i 2020-12-18 22:04

I have a table with a date field. By default, select max(date) from table; returns the date in \'dd-mmm-yy\' format. How do I select the date in \'MM/DD/YYYY\'

相关标签:
4条回答
  • 2020-12-18 22:41

    Exists a table or view v$nls_parameters search here the parameter 'NLS_DATE_FORMAT', this is perfect for not be changing the format each while.

    SELECT * 
      FROM v$nls_parameters WHERE UPPER(PARAMETER) = 'NLS_DATE_FORMAT';
    
    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYYMMDD'; 
    

    There is also the possibility from make for register of win. in tree

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_OraClient11g_home9
    

    Here key NLS_DATE_FORMAT, change for your format date.

    0 讨论(0)
  • 2020-12-18 22:43

    Try the following:

    select to_char(sysdate,'mm/dd/yyyy') as maxdate from dual;
    

    Some information on the oracle-specific function to_char():

    • http://www.techonthenet.com/oracle/functions/to_char.php
    0 讨论(0)
  • 2020-12-18 22:59

    Check out the to_char function and the date/time formats it accepts.

    select to_char(sysdate, 'MM/DD/YYYY')
    from dual;
    
    0 讨论(0)
  • 2020-12-18 23:03
    select to_char(max(date), 'MM/DD/YYYY') from table;
    
    0 讨论(0)
提交回复
热议问题