how can I set all records in the field "published"=0 whose date in field F12 is older than today?
Unfortunately, the field F12 is not a DateTime field, but a string. Unfortunately, I can’t change that. I have to convert the string into a date first.
Unfortunately, this code does not work
UPDATE 'mytable'
SET 'published' = '0'
WHERE STR_TO_DATE('F12', '%d.%m.%Y') DATEDIFF(day, 'F12', NOW()) >= 1
A screenshot of phpMyAdmin is here:
Thank you very much for your support and best regards
2
Answers
I would expect logic like this:
Note that single quotes are being used only for the string constant. That could be the issue with your query. Or it could be that you are using
now()
which has a time component so it also updates values whose date is today.This is not the Answer. its only a Sample for virtual fields:
create a sample table
sample
Now you only set a index on F12new