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
Use TO_CHAR to display it in any format you like. For example: SELECT TO_CHAR ( TO_DATE (date_value, 'yyyy-mm-dd') , 'mm/dd/yyyy' ) FROM table_x; Things are much easier if you store dates in DATE columns.
Oracle stores dates in an internal numeric format representing the century, year, month, day, hours, minutes, seconds. The default date format is DD-MON-YY.
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():
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With