0

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.

0

1 Answer 1

3

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';
Sign up to request clarification or add additional context in comments.

4 Comments

I have read about the to_char but I can't seem to get the syntax correct for it, can you please advise specifically how to enter that using my query?
Yep that's the SCHEMA, TABLE and FIELD. That's exactly what I tried but i get this error when I do: ORA-01481: invalid number format model 01481. 00000 - "invalid number format model" *Cause: The user is attempting to either convert a number to a string via TO_CHAR or a string to a number via TO_NUMBER and has supplied an invalid number format model parameter. *Action: Consult your manual. Please advise.
The date format is fine. The column would appear not to be a date, contrary to what your question says.
Well poop. in that same query if i dont use the... DBSTAGE.DATE_FORMAT( ...and remove the other... ) .... from my original query It outputs the date in the format of 1190214 which is 1+YYMMDD. Does that help come up with a solution?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.