tsql update datetime value
datetime value can be updated using the following query:
e.g. I want to replace the year value with '2012'
update table1
set date = convert(datetime,'2012'+'-'+convert(varchar(3),MONTH(date))+'-'+convert(varchar(3),DAY(date))+' '+ convert(varchar(12),convert(time,date))),
CompletedDate = convert(datetime,'2012'+'-'+convert(varchar(3),MONTH(CompletedDate))+'-'+convert(varchar(3),DAY(CompletedDate))+' '+ convert(varchar(12),convert(time,CompletedDate)))
where [condition]
No comments:
Post a Comment