Reputation: 3025
I am trying to delete a record based on a column called time
(datetime
). Below is my sql statement, and the table which I am working with. SQL server says that 0 records are effected by this query, what am I doing wrong?
DELETE FROM msg WHERE (time = '5/26/2013 8:39:44 PM')
sender receiver msg time
============================================================================
bob jen this is a message 5/26/2013 8:39:44 PM
jen mel Message to pel 5/26/2013 8:44:29 PM
Upvotes: 1
Views: 82
Reputation: 1632
Does it work?
DELETE FROM msg WHERE time = convert(datetime, '5/26/2013 8:39:44 PM', 111)
Upvotes: 0
Reputation: 11233
You can try this SQL fiddle also.
Since you have column time
already of type datetime
so just convert the value to datetime.
Upvotes: 0
Reputation: 13506
try this:
DELETE FROM msg WHERE convert(datetime,time,101) = convert(datetime,'5/26/2013 8:39:44',101)
Upvotes: 1