<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How To:  Calculate the age (in years) of anything using extension methods</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx</link><description>When creating an application that requires a person's age, we typically store the date of birth and calculate their age in years from that. I usually store my user's date of birth in a property of type DateTime. To make it easy to calculate the user's</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: How To:  Calculate the age (in years) of anything using extension methods</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx#7129503</link><pubDate>Fri, 19 Jun 2009 03:30:02 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7129503</guid><dc:creator>Jason Holmes</dc:creator><author>Jason Holmes</author><description>&lt;p&gt;I'm new to asp.net and I was confused by all the code above and after goofing around for a little bit I was able to get this code to work. All I'm doing is determing the persons age based on their Birth Date that I capture when the user signs up on my site. I save the Birth Date as a datetime string. Below is the code I just used.&lt;/p&gt;
&lt;p&gt;int ageindays = (DateTime.Now - pc.BirthDate).Days;&lt;/p&gt;
&lt;p&gt;int age = ageindays / 365;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7129503" width="1" height="1"&gt;</description></item><item><title>Resveratrol</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx#6211220</link><pubDate>Thu, 22 May 2008 20:15:30 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6211220</guid><dc:creator>Resveratrol</dc:creator><author>Resveratrol</author><description>&lt;p&gt;The onset of age related macular degeneration (AMD) may be related to a loss of the ability to constrict the pupil of the eye as one ages. Is there a quantitative measure or test of pupillary constrictive ability- quantifying the“ strongest constrictions&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6211220" width="1" height="1"&gt;</description></item><item><title>re: How To:  Calculate the age (in years) of anything using extension methods</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx#5725636</link><pubDate>Thu, 07 Feb 2008 00:01:37 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5725636</guid><dc:creator>Dave</dc:creator><author>Dave</author><description>&lt;p&gt;Isn't the use of:&lt;/p&gt;
&lt;p&gt;int age = (onDate - birthDate).Year;&lt;/p&gt;
&lt;p&gt;easier to determine the age?&lt;/p&gt;
&lt;p&gt;DateTime has an overloaded operators that handles the totaling and subtraction of dates.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5725636" width="1" height="1"&gt;</description></item><item><title>re: How To:  Calculate the age (in years) of anything using extension methods</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx#5603509</link><pubDate>Mon, 14 Jan 2008 22:24:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5603509</guid><dc:creator>MikeBosch</dc:creator><author>MikeBosch</author><description>&lt;p&gt;Yes. &amp;nbsp;That may be a more appropriate method name. &amp;nbsp;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5603509" width="1" height="1"&gt;</description></item><item><title>re: How To:  Calculate the age (in years) of anything using extension methods</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx#5596752</link><pubDate>Sun, 13 Jan 2008 02:01:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5596752</guid><dc:creator>Alex Hoffman</dc:creator><author>Alex Hoffman</author><description>&lt;p&gt;Wouln't the extension method be better named GetAgeInYears()?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5596752" width="1" height="1"&gt;</description></item><item><title>re: HOW TO:  Calculate the age (in years) of anything using extension methods</title><link>http://weblogs.asp.net/mikebosch/archive/2008/01/10/how-to-calculate-the-age-in-years-of-anything-using-extension-methods.aspx#5585504</link><pubDate>Fri, 11 Jan 2008 04:16:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5585504</guid><dc:creator>vikram</dc:creator><author>vikram</author><description>&lt;p&gt;This was a good use of extension method&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5585504" width="1" height="1"&gt;</description></item></channel></rss>