Home » SQL & PL/SQL » SQL & PL/SQL » How to update only year in date? (oracle 10g)
How to update only year in date? [message #306601] Fri, 14 March 2008 22:39 Go to next message
gentleman777us
Messages: 122
Registered: April 2005
Senior Member
Hi,
I have a table with following data.

TABLE_A
-------
01/01/2007
02/03/2007
04/04/2004
05/23/2002
06/21/2007
02/12/2007


My objective is to update all the date records whose year = 2007
with 2005 year(the month and date should not change)
ex: 01/01/2007 should be 01/01/2005

Thanks
Re: How to update only year in date? [message #306604 is a reply to message #306601] Fri, 14 March 2008 23:17 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
The most comfortable way is using ADD_MONTHS function:
SET <date_column> = ADD_MONTHS( <date_column>, 12*<nr_of_years> )
Re: How to update only year in date? [message #306618 is a reply to message #306601] Sat, 15 March 2008 02:11 Go to previous message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
You are a newbie post in newbie forum.
Why are you posting this question in Expert forum?

It is clearly stated in the forum description: "Newbies should not post to this forum!"
Expert notion is defined in the sticky: Not an EXPERT? Post in the NEWBIES forum, NOT here
Rules are described in: OraFAQ Forum Guide
Read them, follow them.

Regards
Michel
Previous Topic: Aggregate and select in same query?
Next Topic: Dummy variable assignment not releasing pl/sql variable memory
Goto Forum:
  


Current Time: Sat Dec 07 02:29:04 CST 2024