<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://sqlzoo.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://sqlzoo.net/w/index.php?title=Date_arithmetics&amp;feed=atom&amp;action=history</id>
		<title>Date arithmetics - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=Date_arithmetics&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=Date_arithmetics&amp;action=history"/>
		<updated>2013-05-25T13:01:54Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.4</generator>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=Date_arithmetics&amp;diff=1544&amp;oldid=prev</id>
		<title>Marek: Created page with &quot;Group by day of the week (using arithmetic). &lt;div class='ht'&gt; &lt;div class=params&gt;schema:gisq&lt;/div&gt; &lt;div&gt; We can use modular arithmetic to calculate the day of the week.  We hap...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=Date_arithmetics&amp;diff=1544&amp;oldid=prev"/>
				<updated>2012-07-17T15:17:19Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Group by day of the week (using arithmetic). &amp;lt;div class=&amp;#039;ht&amp;#039;&amp;gt; &amp;lt;div class=params&amp;gt;schema:gisq&amp;lt;/div&amp;gt; &amp;lt;div&amp;gt; We can use modular arithmetic to calculate the day of the week.  We hap...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Group by day of the week (using arithmetic).&lt;br /&gt;
&amp;lt;div class='ht'&amp;gt;&lt;br /&gt;
&amp;lt;div class=params&amp;gt;schema:gisq&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
We can use modular arithmetic to calculate the day of the week.&lt;br /&gt;
&lt;br /&gt;
We happen to know that 20 May 1962 was a Sunday. We calculate&lt;br /&gt;
the number of days from that day and take mod 7 value. This tells&lt;br /&gt;
us the day of the week: 0 is Sunday, 1 is Monday...&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sql class='tidy'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=sql class='setup'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def e-oracle'&amp;gt;&lt;br /&gt;
SELECT MOD(wk - TO_DATE('1962-05-20','YYYY-MM-DD'),7),&lt;br /&gt;
       COUNT(song)&lt;br /&gt;
  FROM gisq.totp&lt;br /&gt;
GROUP BY MOD(wk - TO_DATE('1962-05-20','YYYY-MM-DD'),7)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-oracle&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;Dates may be subtracted. The answer is in units of days.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
{{DATE and TIME ref}}&lt;/div&gt;</summary>
		<author><name>Marek</name></author>	</entry>

	</feed>