<?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/"
		>
<channel>
	<title>Comments on: A simple way to make birthday queries easier and faster</title>
	<atom:link href="http://www.xaprb.com/blog/2009/12/31/a-simple-way-to-make-birthday-queries-easier-and-faster/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2009/12/31/a-simple-way-to-make-birthday-queries-easier-and-faster/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 20:41:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Robert</title>
		<link>http://www.xaprb.com/blog/2009/12/31/a-simple-way-to-make-birthday-queries-easier-and-faster/#comment-17613</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Fri, 15 Jan 2010 16:03:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1514#comment-17613</guid>
		<description>I played very long to find a fast solution for querys around the birthdate. Two weeks ago, I wrote about my GETAGE() function, and the first thing I tried to find friends which have birthday in a couple of days was writing a similar function with that body: DATE_ADD(bday, INTERVAL YEAR(FROM_DAYS(DATEDIFF(NOW(), bday) - 1)) + 1 YEAR)

I used this function inside of a trigger and for an update-routine to get a clean column for all of my friends that has birthday in up to one week. This worked for a while, but there are in theory $num_of_users / 365 birthdays per day. With an increasing $num_of_users you also have to update more rows - so I rewrote the system once more. A little intermediate step was using a VARCHAR colum with a REVERSE()&#039;d DATE value to run a LIKE on it. This is also not the best solution because you need more code in the userspace, so I tried a DAY(bday)*100 + MONTH(bday) solution, which is really the best. Especially because you can write a little condition, so that all februry 29 can reduced by 100, if the current year does not have 29 days in that month.</description>
		<content:encoded><![CDATA[<p>I played very long to find a fast solution for querys around the birthdate. Two weeks ago, I wrote about my GETAGE() function, and the first thing I tried to find friends which have birthday in a couple of days was writing a similar function with that body: DATE_ADD(bday, INTERVAL YEAR(FROM_DAYS(DATEDIFF(NOW(), bday) &#8211; 1)) + 1 YEAR)</p>
<p>I used this function inside of a trigger and for an update-routine to get a clean column for all of my friends that has birthday in up to one week. This worked for a while, but there are in theory $num_of_users / 365 birthdays per day. With an increasing $num_of_users you also have to update more rows &#8211; so I rewrote the system once more. A little intermediate step was using a VARCHAR colum with a REVERSE()&#8217;d DATE value to run a LIKE on it. This is also not the best solution because you need more code in the userspace, so I tried a DAY(bday)*100 + MONTH(bday) solution, which is really the best. Especially because you can write a little condition, so that all februry 29 can reduced by 100, if the current year does not have 29 days in that month.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.xaprb.com/blog/2009/12/31/a-simple-way-to-make-birthday-queries-easier-and-faster/#comment-17526</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Fri, 01 Jan 2010 10:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1514#comment-17526</guid>
		<description>I once wrote about it, including indexed way to search for people who have birthday &quot;tomorrow&quot; - it is for PostgreSQL, but shows some pitfalls, and possible solutions:
http://www.depesz.com/index.php/2007/10/26/who-has-birthday-tomorrow/</description>
		<content:encoded><![CDATA[<p>I once wrote about it, including indexed way to search for people who have birthday &#8220;tomorrow&#8221; &#8211; it is for PostgreSQL, but shows some pitfalls, and possible solutions:<br />
<a href="http://www.depesz.com/index.php/2007/10/26/who-has-birthday-tomorrow/" rel="nofollow">http://www.depesz.com/index.php/2007/10/26/who-has-birthday-tomorrow/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Davis</title>
		<link>http://www.xaprb.com/blog/2009/12/31/a-simple-way-to-make-birthday-queries-easier-and-faster/#comment-17521</link>
		<dc:creator>Josh Davis</dc:creator>
		<pubDate>Thu, 31 Dec 2009 22:21:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1514#comment-17521</guid>
		<description>When reading this entry I was thinking about simply storing the &quot;day of the year&quot; value (0 to 365) but then I realized it could complicate things on leap years. If you store them separately, people born on a 29th of February shouldn&#039;t be a problem with

SELECT *
  FROM users
 WHERE (birth_month, birth_day) BETWEEN (2, 27) AND (3, 6)

PS: your CAPTCHA is tricky. It asked me if a lion is a cat and it made check Wikipedia wondering if it was a trick question :)</description>
		<content:encoded><![CDATA[<p>When reading this entry I was thinking about simply storing the &#8220;day of the year&#8221; value (0 to 365) but then I realized it could complicate things on leap years. If you store them separately, people born on a 29th of February shouldn&#8217;t be a problem with</p>
<p>SELECT *<br />
  FROM users<br />
 WHERE (birth_month, birth_day) BETWEEN (2, 27) AND (3, 6)</p>
<p>PS: your CAPTCHA is tricky. It asked me if a lion is a cat and it made check Wikipedia wondering if it was a trick question :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

