NYCPHP Meetup

NYPHP.org

[nycphp-talk] how do you do date math?

Hans Zaunere hans at nyphp.org
Sun Oct 5 11:57:29 EDT 2003



Phil Powell wrote:

> I honestly have found nothing on www.mysql.com <http://www.mysql.com> or 
> anywhere else that can address this problem.  All I simply want to do is 
> to delete rows from a table where nnet_produkt_record_entered is more 
> than 24 hours old.  I thought this would do it but it produces a 
> mysql_error near 'HOURS)':
>  
>    $sql = 'DELETE FROM nnet_produkt_bestilling ' .
>           'WHERE nnet_produkt_placement < DATE_SUB(NOW(), INTERVAL 24 
> HOURS)';

Close, but your syntax is a little off.  Maybe something like:

DELETE FROM nnet_produkt_bestilling
      WHERE nnet_produkt_placement < NOW() - INTERVAL 1 DAY

Although in your text above, you mention nnet_produkt_record_entered so you may want to check that you're using the correct columns.


H






More information about the talk mailing list