<?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>wp-SwimTeam &#187; MySQL</title>
	<atom:link href="http://www.wp-swimteam.org/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wp-swimteam.org</link>
	<description>A WordPress plugin for swim team management</description>
	<lastBuildDate>Tue, 24 Jan 2012 22:21:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WordPress 3.2 will require PHP5</title>
		<link>http://www.wp-swimteam.org/2011/05/17/wordpress-3-2-will-require-php5/</link>
		<comments>http://www.wp-swimteam.org/2011/05/17/wordpress-3-2-will-require-php5/#comments</comments>
		<pubDate>Tue, 17 May 2011 12:20:48 +0000</pubDate>
		<dc:creator>Mike Walsh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.wp-swimteam.org/?p=509</guid>
		<description><![CDATA[WordPress 3.2 beta is out for testing and with it comes several requirements.  The two notable requirements are PHP 5.2.14 or newer and MySQL 5.0 or newer.  I will likely move to 3.2 for wp-SwimTeam development once it is released and I&#8217;ve done some testing with it.  I&#8217;ve been running under PHP5 (5.2.14 and 5.3.x) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wordpress.org/news/2011/05/wordpress-3-2-beta-1/">WordPress 3.2 beta</a> is out for testing and with it comes several requirements.  The two notable requirements are PHP 5.2.14 or newer and MySQL 5.0 or newer.  I will likely move to 3.2 for wp-SwimTeam development once it is released and I&#8217;ve done some testing with it.  I&#8217;ve been running under PHP5 (5.2.14 and 5.3.x) for a while now so I don&#8217;t see this as an issue but it might be for people running on older web hosts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wp-swimteam.org/2011/05/17/wordpress-3-2-will-require-php5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finally fixed age calculation</title>
		<link>http://www.wp-swimteam.org/2008/05/27/finally-fixed-age-calculation/</link>
		<comments>http://www.wp-swimteam.org/2008/05/27/finally-fixed-age-calculation/#comments</comments>
		<pubDate>Tue, 27 May 2008 11:14:15 +0000</pubDate>
		<dc:creator>Mike Walsh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://wp-swimteam.sourceforge.net/?p=26</guid>
		<description><![CDATA[Over the weekend I was speaking with one of the swim team parents who was asking me about our web site and I showed her what she could see about her daughter.  As soon as I popped her daugher&#8217;s information she noticed that she was placed in the wrong age group.  Oops. I had seen [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend I was speaking with one of the swim team parents who was asking me about <a title="MacDolphins" href="http://www.macdolphins.org">our web site</a> and I showed her what she could see about her daughter.  As soon as I popped her daugher&#8217;s information she noticed that she was placed in the wrong age group.  Oops.</p>
<p>I had seen this situation previously but couldn&#8217;t pin it down but now that I had a swimmer I could test against, I dug into it.  It turns out that I had made the age calculation much, much, harder than it really needed to be.  And it was wrong.</p>
<p>I was trying to use MySQL&#8217;s <a title="PERIOD_DIFF" href="http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_period-diff">PERIOD_DIFF()</a> function so the age and cutoff date adjusted age would be returned as part of the query.  It turns out that PERIOD_DIFF() only accounts for months (which I knew when I used it) but not taking into account the days causes the calculation to be wrong and limits the age cutoff date to be the first  of a month which may or may not be acceptable.</p>
<p>My first search yielded <a title="MySQL age calculation example" href="http://mysql-tips.blogspot.com/2005/04/mysql-date-calculations.html">this example</a> which turns out to be wrong as it doesn&#8217;t always return the correct age.</p>
<p>Here is the correct SQL to calculate age:</p>
<pre>SELECT YEAR(birthdate) - (MONTH(CURRENT_DATE()) &lt; MONTH(birthdate)) -
    ((MONTH(CURRENT_DATE()) = MONTH(birthdate)) &amp; (DAY(CURRENT_DATE()) &lt;
    DAY(birthdate))) AS age </pre>
<p>Here is the correct SQL to calcualte age based on a specific cutoff date, in this case the cutoff date is June 1st:</p>
<pre>SELECT YEAR(CURRENT_DATE()) - YEAR(birthdate) - (MONTH('2008-06-01') &lt;
    MONTH(birthdate)) - ((MONTH('2008-06-01') = MONTH(birthdate)) &amp;
    (DAY('2008-06-01') &lt;= DAY(birthdate))) AS agegroupage</pre>
<p>By using the calculations, the swimmer&#8217;s age and age group age are always returned with the query as opposed to computed on the fly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wp-swimteam.org/2008/05/27/finally-fixed-age-calculation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

