leesider
Old Hand
Points: 367
More actions
June 18, 2012 at 9:21 am
#263022
I have a field in a table that I want to update the month (and also the date in certain places).
For example below I might want to change the month (03) to 05 or 06.
2012-03-30 13:57:07.353
Below I might want to change the day (25) to 18 or 19.
2012-04-25 15:59:07.400
Can anyone tell me how I might do this?
Jared
SSC Guru
Points: 61793
June 18, 2012 at 9:25 am
#1502295
The best way would be to use DATEDIFF or DATEADD functions.
So, if you want to change 2012-03-30 13:57:07.353 to 2012-05-30 13:57:07.353 you would do this:
UPDATE tableA
SET dateColumn = SELECT DATEADD(MONTH,2,dateColumn)
WHERE idColumn = something
JaredCE - Microsoft
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply