1

How can i convert the table containing date in text format DY Mon DD YYYY into DD MM YY date format which can be used for sorting when exported to a spread sheet.

The first date format is "Sun Jan 6 2013" which needs to be converted to "06-Jan-13" to be in date format not text which can be sorted on spread sheet and the type of the column is Text.

Thanks in advance.

3
  • please provide an example of your first date format DY Mon DD YYYY Commented Jan 1, 2014 at 13:59
  • what is type of this column? Commented Jan 1, 2014 at 14:01
  • the first date format is "Sun Jan 6 2013" which needs to be converted to "06-Jan-13" to be in date format not text which can be sorted on spread sheet and the type of the column is Text. Commented Jan 1, 2014 at 14:01

1 Answer 1

2

You can convert the text you have to a DATE value, and then re-format it:

SELECT TO_CHAR(TO_DATE(date_column, 'DY MON DD YYYY'), 'DD MM YY')
FROM   my_table
Sign up to request clarification or add additional context in comments.

2 Comments

Just to clarify i was using this earlier, however the output was in text format which didn't enable me to sort date on excel.
@user3139623 In Excel, just format it as date with this format and you should be good to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.