<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webmaster Sucks &#187; current date</title>
	<atom:link href="http://www.webmastersucks.com/tags/current-date/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webmastersucks.com</link>
	<description>Here I share stuff I used to suck at as a novice webmaster..</description>
	<lastBuildDate>Tue, 11 May 2010 10:56:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calculate Last Week, Last Month in Mysql</title>
		<link>http://www.webmastersucks.com/calculate-last-week-last-month-in-mysql/</link>
		<comments>http://www.webmastersucks.com/calculate-last-week-last-month-in-mysql/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:49:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[curdate]]></category>
		<category><![CDATA[current date]]></category>
		<category><![CDATA[date calculation]]></category>
		<category><![CDATA[date_add]]></category>
		<category><![CDATA[last month]]></category>
		<category><![CDATA[last week]]></category>
		<category><![CDATA[yesterday]]></category>

		<guid isPermaLink="false">http://www.webmastersucks.com/?p=52</guid>
		<description><![CDATA[
			
				
			
		
We need get datas from last week, last month, yesterday and today. We can do it easily in MySQL.
Getting Current Date
SELECT CURDATE();
Result : 2009-06-04
Getting Last Week Datas
SELECT DATE_ADD('2009-06-04', INTERVAL 7 DAY);
Getting Last Month Datas
SELECT DATE_ADD('2009-06-04', 1 MONTH);
Getting Last Year Datas
SELECT DATE_ADD('2009-06-04', INTERVAL 1 YEAR);
And Php example for this calculations, getting last month orders
mysql_query(&#34;SELECT * FROM [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.webmastersucks.com%2Fcalculate-last-week-last-month-in-mysql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.webmastersucks.com%2Fcalculate-last-week-last-month-in-mysql%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>We need get datas from last week, last month, yesterday and today. We can do it easily in MySQL.</p>
<p><strong>Getting Current Date</strong></p>
<pre class="brush: plain;">SELECT CURDATE();</pre>
<p><strong>Result :</strong> 2009-06-04</p>
<p><strong>Getting Last Week Datas</strong></p>
<pre class="brush: plain;">SELECT DATE_ADD('2009-06-04', INTERVAL 7 DAY);</pre>
<p><strong>Getting Last Month Datas</strong></p>
<pre class="brush: plain;">SELECT DATE_ADD('2009-06-04', 1 MONTH);</pre>
<p><strong>Getting Last Year Datas</strong></p>
<pre class="brush: plain;">SELECT DATE_ADD('2009-06-04', INTERVAL 1 YEAR);</pre>
<p>And Php example for this calculations, getting last month orders</p>
<pre class="brush: php;">mysql_query(&quot;SELECT * FROM orders WHERE DATE_SUB(CURDATE(),INTERVAL 1 month) &lt;= order_date&quot;)); </pre>
<p>For more information of Date and time functions :<br />
<a href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html">http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webmastersucks.com/calculate-last-week-last-month-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
