Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mash update date value, how?

Status
Not open for further replies.

babeo

Technical User
Mar 30, 2000
398
CA
Hello,

Due to problem of machine, and all data of that date is changed (not current year), now I want to change all of them to current year, but want to have a code generate the change, is there anyone could help me this?
The bad data is looked like as "06/20/2007 13:00:09" , notices that the date is consitent, but the time is not, the time can be any time, it means "06/20/2007 28:40:29" or "06/20/2007 22:29:50', and this is the problem for me.

I want to do something like:
update TABLEA set DATEField = '06/20/2004 ??:??:??' where DATEField contains '06/20/2007%'
Is this possible?

Thanks
 
I got the answer by myself.

update table_name
set column_name = dateadd (year, -xx, column_name)
where column_name > dateadd (year,1,getdate())

where xx is the different number of the current year with the bad year, eg: current: 2004, bad year: 2007, then xx = 3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top