0

Can I know what is wrong with my sql statement below. I gives an error "incorrect datetime value".

UPDATE stocks SET  Notes = '0' where ExpireDate like '%2017-12-28%' and StockCount > 0;
Pathum
  • 18
  • 3

1 Answers1

1

Try this:

SET sql_safe_updates = 0;
UPDATE STOCKS
SET NOTES = '0'
WHERE EXPIREDATE = CURDATE()
AND STOCKCOUNT > 0;
SET sql_safe_updates = 1;

DEMO

Hasaan Mubasher
  • 120
  • 1
  • 6
S_sauden
  • 302
  • 2
  • 10
  • It still does not work. Gives the error "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode" – Pathum Dec 29 '17 at 05:06
  • Actually what I need is to get today's date and if it matches with the expire date of a product, change the status to expire.. please tell me if there is any other way to do this or if there is any mistake in my sql. – Pathum Dec 29 '17 at 05:09