Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
fralo
Posting Yak Master
161 Posts |
Posted - 2013-01-22 : 11:02:55
|
I have a date field with many dates showing the year 1901 which I need to update to 2001. Is there a way to do this?I know there is a DATEPART function which allows searching only for the year portion of a field (i.e. DATEPART(yy, date_field)).Can I run an update which will update all rows with a date of 1901-??-?? to 2001-??-??Thanks for any help you could provide. |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2013-01-22 : 11:18:28
|
Maybe just thisUPDATE yourTableSET yourDate = DATEADD(year,100,yourDate)WHERE yourDate between '19010101' and '19011231'JimEveryday I learn something that somebody else already knew |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2013-01-22 : 11:29:35
|
Hey you an alright fella!That worked. Thanks a lot. |
|
|
|
|
|