<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Quick Tip:  MySQL&#160;date_add</title> <atom:link href="http://davidwalsh.name/mysql-date-add/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mysql-date-add</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 14:01:31 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Tom</title><link>http://davidwalsh.name/mysql-date-add#comment-18027</link> <dc:creator>Tom</dc:creator> <pubDate>Sat, 05 Jun 2010 22:46:51 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-18027</guid> <description>Or you can use this: DATE_SUB(NOW(), INTERVAL 1 DAY)</description> <content:encoded><![CDATA[<p>Or you can use this: DATE_SUB(NOW(), INTERVAL 1 DAY)</p> ]]></content:encoded> </item> <item><title>By: Metric Stormtrooper</title><link>http://davidwalsh.name/mysql-date-add#comment-17858</link> <dc:creator>Metric Stormtrooper</dc:creator> <pubDate>Tue, 25 May 2010 23:12:56 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17858</guid> <description>@Metric Stormtrooper:  SELECT * FROM logs WHERE logstamp = &#039;::php today() ::&#039;hm, cant post php syntax here, but you get the idea</description> <content:encoded><![CDATA[<p>@Metric Stormtrooper:  SELECT * FROM logs WHERE logstamp = &#8216;::php today() ::&#8217;</p><p>hm, cant post php syntax here, but you get the idea</p> ]]></content:encoded> </item> <item><title>By: Metric Stormtrooper</title><link>http://davidwalsh.name/mysql-date-add#comment-17857</link> <dc:creator>Metric Stormtrooper</dc:creator> <pubDate>Tue, 25 May 2010 23:10:14 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17857</guid> <description>@Niklas Berglund:  your query must be deterministic – query might provide same result no matter how many times it is run, if data remains the same. So if your query uses non-deterministic functions such as NOW(), UUID(), RAND(), CONNECTION_ID() etc it will not be cached.
However, if you pass in a fixed value from PHP as inSELECT * FROM logs WHERE logstamp = &#039;&#039;it will be cached.(the php function today() is just a one-liner that returns the current day in mysql format)</description> <content:encoded><![CDATA[<p>@Niklas Berglund:  your query must be deterministic – query might provide same result no matter how many times it is run, if data remains the same. So if your query uses non-deterministic functions such as NOW(), UUID(), RAND(), CONNECTION_ID() etc it will not be cached.<br
/> However, if you pass in a fixed value from PHP as in</p><p>SELECT * FROM logs WHERE logstamp = &#8221;</p><p>it will be cached.</p><p>(the php function today() is just a one-liner that returns the current day in mysql format)</p> ]]></content:encoded> </item> <item><title>By: DeMx</title><link>http://davidwalsh.name/mysql-date-add#comment-17780</link> <dc:creator>DeMx</dc:creator> <pubDate>Fri, 21 May 2010 20:42:28 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17780</guid> <description>This query will not be used index.</description> <content:encoded><![CDATA[<p>This query will not be used index.</p> ]]></content:encoded> </item> <item><title>By: Niklas Berglund</title><link>http://davidwalsh.name/mysql-date-add#comment-17775</link> <dc:creator>Niklas Berglund</dc:creator> <pubDate>Fri, 21 May 2010 16:15:44 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17775</guid> <description>@Jeremy Parrish:  Why didnt I think of this? :) Thanks!</description> <content:encoded><![CDATA[<p>@Jeremy Parrish:  Why didnt I think of this? :) Thanks!</p> ]]></content:encoded> </item> <item><title>By: Jeremy Parrish</title><link>http://davidwalsh.name/mysql-date-add#comment-17774</link> <dc:creator>Jeremy Parrish</dc:creator> <pubDate>Fri, 21 May 2010 15:56:21 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17774</guid> <description>If you want caching to work, you can truncate the time part like this:$yesterday = strtotime(&#039;-1 day&#039;);
$yesterday_str = date(&#039;Y-m-d 00:00:00&#039;, $yesterday);Then it&#039;ll be good for the whole day. This has the added benefit of matching the logical meaning of &quot;yesterday&quot; rather than being precicely 24 hours ago.</description> <content:encoded><![CDATA[<p>If you want caching to work, you can truncate the time part like this:</p><p>$yesterday = strtotime(&#8216;-1 day&#8217;);<br
/> $yesterday_str = date(&#8216;Y-m-d 00:00:00&#8242;, $yesterday);</p><p>Then it&#8217;ll be good for the whole day. This has the added benefit of matching the logical meaning of &#8220;yesterday&#8221; rather than being precicely 24 hours ago.</p> ]]></content:encoded> </item> <item><title>By: Niklas Berglund</title><link>http://davidwalsh.name/mysql-date-add#comment-17772</link> <dc:creator>Niklas Berglund</dc:creator> <pubDate>Fri, 21 May 2010 15:28:07 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17772</guid> <description>Hmm good tip indeed, but... The queries still cannot be cached if you use something as dynamic as strtotime(&#039;now&#039;), isn&#039;t that right?So using strtotime() does not enable the query to be cached? Or am I wrong?
strtotime() would only give you an advantage if the same query is run during the same second?</description> <content:encoded><![CDATA[<p>Hmm good tip indeed, but&#8230; The queries still cannot be cached if you use something as dynamic as strtotime(&#8216;now&#8217;), isn&#8217;t that right?</p><p>So using strtotime() does not enable the query to be cached? Or am I wrong?<br
/> strtotime() would only give you an advantage if the same query is run during the same second?</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/mysql-date-add#comment-17771</link> <dc:creator>David Walsh</dc:creator> <pubDate>Fri, 21 May 2010 15:17:47 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17771</guid> <description>@macol:  Ohhhh, good tip!</description> <content:encoded><![CDATA[<p>@macol:  Ohhhh, good tip!</p> ]]></content:encoded> </item> <item><title>By: macol</title><link>http://davidwalsh.name/mysql-date-add#comment-17770</link> <dc:creator>macol</dc:creator> <pubDate>Fri, 21 May 2010 14:38:06 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17770</guid> <description>I prefer using php function strtotime() because queries using MySQL functions like NOW() can&#039;t be cached</description> <content:encoded><![CDATA[<p>I prefer using php function strtotime() because queries using MySQL functions like NOW() can&#8217;t be cached</p> ]]></content:encoded> </item> <item><title>By: Niklas</title><link>http://davidwalsh.name/mysql-date-add#comment-17769</link> <dc:creator>Niklas</dc:creator> <pubDate>Fri, 21 May 2010 13:50:30 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4971#comment-17769</guid> <description>Or you can do it like this: date_starts &gt;= NOW() - INTERVAL 1 DAY
Easier to read in my opinion :) Good tip! I do it like this quite often</description> <content:encoded><![CDATA[<p>Or you can do it like this: date_starts &gt;= NOW() &#8211; INTERVAL 1 DAY<br
/> Easier to read in my opinion :) Good tip! I do it like this quite often</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 2/8 queries in 0.007 seconds using disk: basic
Object Caching 804/806 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 11:06:16 -->
