Gayathri
Gayathri

Reputation: 349

How to convert Varchar to Date?

I have a table - Order and I have a field "Order_Date" which is in Varchar format - '20150804'.

select order_date from order
output- 20150804

I want to convert order_date- '20150804' into Date format- '07-SEP-15'

Upvotes: 0

Views: 8198

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172378

Try this:

select to_char(to_date('20150804', 'yyyymmdd'), 'dd-MON-yy') from dual;

In your actual query it would be like:

select to_char(to_date(order_date, 'yyyymmdd'), 'dd-MON-yy') from order

Upvotes: 4

Related Questions