Home » SQL & PL/SQL » SQL & PL/SQL » Extract Year
Extract Year [message #212069] Wed, 03 January 2007 12:30 Go to next message
pradkuamr
Messages: 29
Registered: November 2006
Junior Member
Hi Friends
Wish you all a Happy New Year 2007

I need to extract year from a column called Creation_Date

I used the following syntax:
SELECT to_char(to_date('CREATION_DATE', 'YYYY/MM/DD HH:MI PM'),'YYYY') from Table_name

It is giving out an error:
ORA-01841: (full) year must be between -4713 and +9999, and not be 0

Myc reation_date are from year 2000 until 2006

Any idea over this error
Re: Extract Year [message #212070 is a reply to message #212069] Wed, 03 January 2007 12:34 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
If it's a DATE column as it should be, you don't do a TO_DATE on it, and you don't put a column name in single quotes.

Simply do
to_char(CREATION_DATE,'YYYY')
Re: Extract Year [message #212071 is a reply to message #212069] Wed, 03 January 2007 12:37 Go to previous message
pradkuamr
Messages: 29
Registered: November 2006
Junior Member
Thank You..Its working now
Previous Topic: Difference between Table and Materialized View
Next Topic: pass a value through a query
Goto Forum:
  


Current Time: Sun Dec 04 16:33:12 CST 2016

Total time taken to generate the page: 0.09907 seconds