Re: [PHP-DB] CURDATE()

2011-08-19 Thread who.cat
I tried on my db
select count(*) from my_table where col_timestampcurdate();
the column col_timestamp type is timestamp,this sql works well.
hope it helpful.

All you best

What we are struggling for ?
The life or the life ?



On Thu, Aug 18, 2011 at 5:21 PM, Geoff Lane ge...@gjctech.co.uk wrote:

 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




[PHP-DB] CURDATE()

2011-08-18 Thread Ron Piggott

I am setting up a daily cron job to update the site map on my web site.  

I want to delete any records that weren’t updated by the cron job each day.  
The way I can distinguish this is with the timestamp column named 
“last_record_update”  If a record wasn’t updated it is no longer part of the 
web site. 

I am trying to figure out if there is a way for me to use mysql’s date 
functions to query the records that are no longer part of the web site.

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

The reason I wanted to use % is because the time will follow the date in a 
“timestamp” column

Is there a similar way to do what I am trying:

SELECT `reference` FROM `sitemap_pages` WHERE `last_record_update` NOT LIKE  ( 
CURDATE() . % ) ORDER BY `reference` +0

Thanks for helping.  

Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info  


Re: [PHP-DB] CURDATE()

2011-08-18 Thread Geoff Lane
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



[PHP-DB] CURDATE

2010-08-16 Thread Ron Piggott
I am wondering why:

SELECT * FROM `bible_concordance_usage` WHERE `date_accessed` = CURDATE()

Doesn't work when `date_accessed` is column type timestamp

And

What would work?

Ron




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



Re: [PHP-DB] CURDATE

2010-08-16 Thread kesavan trichy rengarajan
Try:
DATE(date_accessed) = CURDATE().

Have a look at this:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dateto
understand what's happening.

Regards,
Kesavan.

On 17/08/2010 6:26 AM, Ron Piggott ron.pigg...@actsministries.org wrote:

I am wondering why:

SELECT * FROM `bible_concordance_usage` WHERE `date_accessed` = CURDATE()

Doesn't work when `date_accessed` is column type timestamp

And

What would work?

Ron




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


Re: [PHP-DB] CURDATE

2010-08-16 Thread Aleksei Sapunov
Hi all,
I have a big question - why on this list raised question about MySQL or any
other database without any relation to PHP? Is it list for solving SQL and
DB problems? When I subscribe to this list I think that this list is about
PHP DB problems. At least problems related to PHP - but not about problems
about MySQL or any other db or their functions ... whats wrong?

2010/8/16 kesavan trichy rengarajan k...@trk7.com

 Try:
 DATE(date_accessed) = CURDATE().

 Have a look at this:

 http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dateto
 understand what's happening.

 Regards,
 Kesavan.

 On 17/08/2010 6:26 AM, Ron Piggott ron.pigg...@actsministries.org
 wrote:

 I am wondering why:

 SELECT * FROM `bible_concordance_usage` WHERE `date_accessed` = CURDATE()

 Doesn't work when `date_accessed` is column type timestamp

 And

 What would work?

 Ron




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