Topic: Compare two dates and update Fields

Hi,
I just need to have a query to update my records by compare two dates!
But cannot manage to make it sad

something like this :

UPDATE sampletable SET myfield=1 where DATEDIFF(TODAY,DATEFIELD) >= 7;

so How can I do it ?
Thanks a lot smile

Re: Compare two dates and update Fields

for MySQL:

UPDATE sampletable SET myfield=1 where DATEDIFF(now() ,DATEFIELD) >= 7;
Dmitry.

Re: Compare two dates and update Fields

Thanks a lot Dear Dimitri.

4 (edited by sonixax 2016-06-22 20:34:59)

Re: Compare two dates and update Fields

Dear Dimitri,
Ive just use these queries :

     SQLExecute('UPDATE records SET unpaidOrange=1 where DATEDIFF(day, now() ,date) BETWEEN 7 AND 14;');
     SQLExecute('UPDATE records SET unpaidRed=1 where DATEDIFF(day, now() ,date) >= 14;');



and got this error :

http://i63.tinypic.com/11761a8.png

(my date field in database called date!)

How can I solve it ?
Thanks a lot smile

Re: Compare two dates and update Fields

sonixax
I corrected my example in previous answer. Just remove word "day"

Dmitry.

Re: Compare two dates and update Fields

Thanks a lot smile it worked tongue