1

I have dates in a table saved in varchar2 field, oracle database.

Example

6/30/2012 6/30/2013

I'm trying to extract year. Any ideas for extracting year other than using substr function?

user1751356
  • 565
  • 4
  • 14
  • 33
  • 5
    Never, ever store dates in a varchar column. You should migrate that to a proper `DATE` column as soon as possible. –  Apr 26 '13 at 19:15
  • 2
    `update yourtable set yourcolumn = to_date(yourcolumn,'dd/mm/yyyy')` should do the trick for you ((That's assuming that you at least have your rows in the format you gave as an example)) – Scotch Apr 26 '13 at 19:17

1 Answers1

2

Convert to a date, and then get the year using date functions:

Convert a string date into datetime in Oracle

Community
  • 1
  • 1
Limey
  • 2,642
  • 6
  • 37
  • 62