Re: CURDATE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, August 18, 2011, Ron Piggott wrote;

> What I tried below doesn?t work:  ( CURDATE() . % )

Even though date values are presented like strings, they are
dates/times. So you need to either cast CURDATE() to a string or else
perform 'date arithmetic'. Check the manual for DATEDIFF(), CAST(),
and CONVERT().

> NOT LIKE  ( CURDATE() . % )

I suspect that PHP's concatenation operator (the period) isn't
recognised by MySQL (assuming that's the DB you're using). So you need
to either use MySQL's CONCAT() function or else create the search
string in PHP rather than MySQL. However, if you're going to do this,
you need to also cast last_record_update to a string.

Personally, I'd use:
   WHERE DATEDIFF(CURDATE(), last_record_update) > 1
(testing for 1 rather than 0 just in case the date rolled over between
the update and the 'stale record' check.)

HTH,

-- 
Geoff


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux