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 |
|
apantig
Posting Yak Master
104 Posts |
Posted - 2006-01-12 : 00:52:55
|
| Hi guys,Thanks for the recent help.Now, how can I update the YEAR?Sample Data11-23-190311-20-190301-04-1903Thank you. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-12 : 00:59:53
|
quote: Originally posted by apantig Hi guys,Thanks for the recent help.Now, how can I update the YEAR?Sample Data11-23-190311-20-190301-04-1903Thank you.
Do you want to update them to 2006?What is your expected result?MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-12 : 01:01:23
|
you mean change all the year to a diff year or something else ?create table #temp( dt datetime)delete #tempinsert into #tempselect '11-23-1903' union allselect '11-20-1903' union allselect '01-04-1903'declare @year intselect @year = 2006select * from #tempupdate #temp set dt = dateadd(year, @year - 1900, dateadd(year, 1900 - year(dt), dt))select * from #tempdrop table #temp -----------------'KH'Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. |
 |
|
|
apantig
Posting Yak Master
104 Posts |
Posted - 2006-01-12 : 01:02:15
|
| The user input was wrong. Instead of 2003, they input 1903. These records came from data migration. I expect year 2003.Thank you |
 |
|
|
apantig
Posting Yak Master
104 Posts |
Posted - 2006-01-12 : 01:14:33
|
| Khtan,Thank you. It works now and records are updated.Thanks and more power. |
 |
|
|
apantig
Posting Yak Master
104 Posts |
Posted - 2006-01-12 : 01:15:35
|
| Khtan,Thank you. It works now and records are updated.Thanks and more power. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-12 : 01:21:52
|
| You are welcomeYou are welcome-----------------'KH'Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. |
 |
|
|
|
|
|
|
|