Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Posts
    12

    Unanswered: Changing year in field

    Hi all:
    I need to change the year to many records that, by mistake, were put with a 2007 date, but they should be still with 2006, can anyone help me ?

    I use Sql Server 2000 and the field is of type datetime

    Thanks

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    first make a backup.

    then write a select statement for the rows that need to be updated, and make sure it's correct (that is, it contains all the rows that need fixing, and no others):
    Code:
    select * from mytable where <some criteria>
    then you can apply an update.
    Code:
    update mytable 
    set mycol=dateadd(year, -1, mycol) 
    where <some criteria>

Posting Permissions

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