Oracle - Date time special format

Hi

I have a varchar2 Oracle field called "" that contains a special date time format "YYYY-MM-DD"T"HH:MM:SS". Ex: 2018-09-02T19:30:00

From that date, i would like to get the day name of it. In above example, "Sun" would be the day of August 2 2018.

I tried multiple TO_CHAR(TO_DATE(DATE_TIME_START but does not recognize the value as a date. How can i do that?

Select  ID, CUSTOMER, DATE_TIME_START from Schedule where DATE_TIME_START = 'SUN'

Open in new window


Thank you for your help
LVL 11
Wilder1626Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Try this:
select to_char(to_date('2018-09-02T19:30:00', 'YYYY-MM-DD"T"HH24:MI:SS'),'Dy')
from dual;

Open in new window

0
slightwv (䄆 Netminder) Commented:
I suppose I should have completed it:
Select  ID, CUSTOMER, DATE_TIME_START from Schedule where to_char(to_date(DATE_TIME_START, 'YYYY-MM-DD"T"HH24:MI:SS'),'Dy') = 'Sun';

Open in new window


Whenever I hear of a date/time stored as a string, there are data conversion issues.  I expect data problems.  If you can create a function, there are a few examples out there that validate strings as dates.  If that is an option ,we would need to know what you would like returned for bad data.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wilder1626Author Commented:
Thank you. This is working. Unfortunately, I don't have control over the database since i only have a read only access. But it's good to know about potential problems with date / time as a string.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.