How to display date in a different format in oracle
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' format, without changing the table 's structure or the field's format.
Thanks, Supraja
select to_char(max(date), 'MM/DD/YYYY') from table;
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
Check out the to_char function and the date/time formats it accepts.
select to_char(sysdate, 'MM/DD/YYYY')
from dual;
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.
精彩评论