-1

I have table name "info" with column "lastupdated" (datatype is datetime),I just want to update all record where "updatedOn" is not equal to currentdate/today's date

Here is my table "info"

id      status      lastupdated
1       1           2010-01-01 13:25:02 
2       NULL        2010-01-03 14:05:02
3       1           2010-01-02 13:30:01

I tried with following query but not working,Where i am wrong ?

UPDATE info SET status = NULL
WHERE lastupdated != '2020-01-03'
amit
  • 1
  • 1
  • 18
  • 28
  • Note that DATE() cannot use an index. So, `NOT BETWEEN '2020-01-03 00:00:00' AND '2020-01-03 23:59:59'` would be more performant (if said index were available) – Strawberry Jan 03 '20 at 10:26
  • I have downvoted because if I can find at least 5 duplicates to close with, then the question is probably "under-researched". – mickmackusa Jan 03 '20 at 10:44

2 Answers2

0

You can use DATE() function of mysql to compare

UPDATE info SET status = NULL
WHERE DATE(lastupdated ) != '2020-01-03'
Devsi Odedra
  • 5,244
  • 1
  • 23
  • 37
0

Try with Date() function

UPDATE info SET status = NULL WHERE DATE(lastupdated) != '2020-01-03'
Swetha Sekar
  • 237
  • 1
  • 9