简体   繁体   中英

What is the correct syntax for Date format in Oracle SQL Developer

Oracle SQL Developer Version 18.2.0.183, Build 183.1748 (READ ONLY ACCESS TO DB FOR QUERIES)

My query is as follows:

SELECT 
DBSTAGE.DATE_FORMAT(DBSTAGE.OAWOM.CHECKINDATE) "Checked In Date MM/DD/YYYY"
FROM 
DBSTAGE.OAWOM
WHERE
DBSTAGE.OAWOM.WOSTATUS = 'CP'

In the CHECKINDATE field portion of My query it returns data in the date format of 15-FEB-19 which is a DD-MM-YY format. I need it to instead be in the format of MM/DD/YYYY. I don't know how to accomplish that, Please help.

In Oracle, you use to_char() to convert the date to a string in the format you want:

select to_char(datecol, 'MM/DD/YYYY')

For specifying literals in a query, I strongly recommend the date keyword with YYYY-MM-DD standard format:

select date '1776-07-04'

You seem to want:

SELECT TO_CHAR(o.CHECKINDATE, 'MM/DD/YYYY') as checkindate_mmddyyyy
FROM DBSTAGE.OAWOM o
WHERE o.WOSTATUS = 'CP';

EDIT:

You may need the function DBSTAGE.DATE_FORMAT() to convert your column to a valid date format:

SELECT TO_CHAR(DBSTAGE.DATE_FORMAT(o.CHECKINDATE), 'MM/DD/YYYY') as checkindate_mmddyyyy
FROM DBSTAGE.OAWOM o
WHERE o.WOSTATUS = 'CP';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM