Solved

Updating a date field in PL/SQL

Posted on 2008-10-31
3
896 Views
Last Modified: 2013-12-19
I would like to know the easiest way to update a date field in pl/sql.  I have a date field that was imported incorrectly from an .csv file into my oracle table.

The date field came in as follows:
08/24/0001 which should be 08/20/2001
09/01/0098 which should be 09/01/1998

Please help.
0
Comment
Question by:ewgf2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
dbmullen earned 350 total points
ID: 22854946
assuming there are no rows in the future (ie.. 2009, 2010, 2011...)

update tablea
set date_column = add_months(date_column,12 * 2000)
where to_char(date_column,'yyyy') between '0000' and '0008'
;

update tablea
set date_column = add_months(date_column,12 * 1900)
where to_char(date_column,'yyyy') between '0009' and '0099'
;

commit;
0
 
LVL 9

Assisted Solution

by:jamesgu
jamesgu earned 150 total points
ID: 22855017
update a
set d = case when d > to_date('01/01/0050') then add_months(d, 1900 * 12)
else add_months(d, 2000 * 12)
end
;
--d is the column name

0
 

Author Closing Comment

by:ewgf2002
ID: 31512222
I wish to thank you both.  dbmullen's solution narrowed the results to what i needed.  both solutions will work thought.  thanks again.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question