Birthday diplayed as age .NET, ASP.NET, VB.NET

I needed to display the age of of a birthday field from a database. I was so tired of coding and came across this function!

I got this from a guy named "hans" on a forum, great little function I didn't have to write!

Private Function
Age(ByVal Birthday As DateTime) As Integer
Dim
year As Integer = Today.Year - Birthday.Year
If Today.Month < Birthday.Month Or (Today.Month = Birthday.Month And Today.Day < Birthday.Day) Then
Return
year - 1
Else
Return
year
End If
End Function



posted @ Saturday, February 07, 2009 5:53 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 5 and 6 and type the answer here:
 

Live Comment Preview:

 

Over 13 years of Internet experience and website marketing. Tim Maxey's Tech Blog. Set out to help the lives of others by making their programming easier. No one is the "best" programmer, every good programmer knows that, or should. Always keep learning and if you do not like it, get out of it. Do what makes you happy! My main purpose is to help youth and also anyone for that matter learn they can make a good living in technology!