DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Update partial Values

  1. #1
    Join Date
    Dec 2000
    Location
    Virginia, USA
    Posts
    455
    How do I update partial value.

    Example:
    I have emp table with column hiredate, Hiredate has values like
    11-AUG-98
    10-OCT-88
    12-OCT-88
    11-OCT-89
    .....
    .....

    I want to keep the date same but only change year where year = 88 to 2001.
    so Result will be as shown below

    11-AUG-98
    10-OCT-01
    12-OCT-01
    11-OCT-89
    .....
    .....

    Thanks in advance

  2. #2
    Join Date
    Feb 2001
    Location
    Paris, France
    Posts
    809
    update emp
    set hiredate = add_months(hiredate,36)
    where to_char(hiredate,'YYYY') = 1988;

  3. #3
    Join Date
    Feb 2001
    Location
    Paris, France
    Posts
    809
    sorry, 36 months is for 3 years, just put 156 instead of 36

  4. #4
    Join Date
    Feb 2001
    Posts
    184
    Here is the easy method and Looks Good
    Alter session set nls_date_format = 'DD-MON-YYYY';
    Update Emp
    Set Hiredate = Substr(Hiredate,1,7)||'9999'
    Where substr(Hiredate,8) between 1988 and 2001;

    This is fine and Provide the year in four digit year that you want to have.

    then Issue
    Alter session set nls_date_format = 'DD-MON-YY';

    Thanks



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width