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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update date not updating

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-03-31 : 08:27:12
I am trying to change the date in an existing table from 12/4/2009 12:00:00 AM to 03/19/2010 12:00:00 AM but it's not taking. This is what I'm using:



UPDATE CurrentDiaryx
SET week_start_date = REPLACE(week_start_date, '12/4/2009 12:00:00 AM', '03/19/2010 12:00:00AM')

Kristen
Test

22859 Posts

Posted - 2010-03-31 : 08:40:02
[code]
UPDATE CurrentDiaryx
SET week_start_date = '20100319'
WHERE week_start_date = '20091204'
[/code]
Note that "string dates" in other formats are unreliable, and parsing them correctly is dependent on a number of factors, so best to stick to 'yyyymmdd' (important that there are no hyphens) or 'yyyy-mm-ddThh:mm:ss.sss' - this one does need hyphens
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-03-31 : 08:47:48
Thank you and for explaining it to me as well!
Go to Top of Page
   

- Advertisement -