I am writing an SQL statement to select dates from a table and creates a file. I want to convert date to string mm/dd/yyyy. Any help would be greatly appreciated.
select startdate from table;
this date is displayed as 31-MAY-15 so I want it displayed as 05-31-2015
SELECT
TO_CHAR(empl.term_date,'MM-DD-YYYY') as "Term Date"
FROM prod.employee empl
You can learn more concerning the possible date formats from here: https://docs.oracle.com/c.../sql_elements004.htm One quirk of Lawson to be aware of is that it doesn't use NULL values in SQL for dates. Instead any empty dates are represented by the date 01/01/1700. So you might want to roll this into a CASE statement to cover that possibility:
CASE
WHEN empl.term_date = TO_DATE('01/01/1700','MM/DD/YYYY')
THEN ''
ELSE
TO_CHAR(empl.term_date,'MM-DD-YYYY')
END as "Term Date"