user1896796
user1896796

Reputation: 749

Finding and replacing the time stamp data in mysql

I have a mysql database with table description as

time_stamp column is having value in date time data type like '2013-08-12 12:12:34' Like this there are multiple records .

I want to replace the records where value is like '2013-08-12 % ' to '2013-08-13 %'. I dont want to change the hh:mm:ss values in time_stamp.

How can i do this .

Upvotes: 2

Views: 389

Answers (2)

user2645436
user2645436

Reputation: 64

You Can try following query,

UPDATE tablename SET time_stamp = concat('2011-08-13 ', time(time_stamp)) 

Upvotes: 2

mvp
mvp

Reputation: 116187

This should work fast if there is an index on time_stamp column:

UPDATE mytable
SET time_stamp = time_stamp + INTERVAL 1 DAY
WHERE time_stamp >= '2013-08-12'
  AND time_stamp <  '2013-08-13'

Upvotes: 1

Related Questions