heart1possible
heart1possible

Reputation: 7

convert oracle date format based on user input

I have a oracle form that the user loads data. The date format the user uses is different than what I have in my list of values. Need help in adding this format

SELECT
  TO_CHAR(TO_DATE( 'Sunday, November 4, 2018', 'DD MON YYYY' ))
FROM
  DUAL;

Convert to '11/4/2018'.

user date format

Upvotes: 0

Views: 277

Answers (1)

GMB
GMB

Reputation: 222672

You can convert a string like 'Sunday, November 4, 2018' to a DATE datatype with this expression:

TO_DATE( 'Sunday, November 4, 2018', 'Day, Month DD, YYYY' )

Then it is possible to convert the date to a string in another format with TO_CHAR().

You seem to be looking for:

SELECT 
    TO_CHAR(TO_DATE( 'Sunday, November 4, 2018', 'Day, Month DD, YYYY' ), 'MM/DD/YYYY') 
FROM DUAL;

This yields:

11/04/2018

Demo on DB Fiddle

Upvotes: 1

Related Questions