Link to home
Start Free TrialLog in
Avatar of endrec
endrec

asked on

How to update a date via T-SQL? The following script is not working.

I am trying to update the date in a table to the current date/time (done), then update it to another specific date that is not the current date and time.  When I try to use something other than GETDATE() the update does not seem to work.
--The following does work
UPDATE Masters
 SET UpdateDate=GETDATE()
 WHERE Masterid='4512'
 
--The following examples do not work...I need to be able to change the dates back to specific dates/times as we are testing if changing the dates affects something in an undocumented process.
 
UPDATE Masters
 SET UpdateDate='2007-10-16 09:47:51.577'
 WHERE Masterid='4512'
 
UPDATE Masters
 SET UpdateDate=CAST('2007-10-16 09:47:51.577' AS DATETIME)
 WHERE Masterid='4512'

Open in new window

Avatar of ee_rlee
ee_rlee
Flag of Philippines image

hi

i don't see anything wrong with the query. are getting errors?
ASKER CERTIFIED SOLUTION
Avatar of drydenhogg
drydenhogg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of endrec
endrec

ASKER

You were right, there is an update trigger that changes the UPDATEDATE to GETDATE() every time any changes are made to a record.
Forced accept.

Computer101
EE Admin