Problem: I have a table that list the person DOB.
I have a field (called Person_DOB) that I can use to grab the person DOB from the database. I would like to grab the person year they were born and compare it with the current year we are in.
Ex. 1988-09-26 00:00:00.000
I have a field that I can call that contains the DOB of the person. How can I covert that to a date and calculate their age using C#?
I have tried the following but it appears to not work:
<%
int now = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
int dob = int.Parse("Person_DOB".ToString("yyyyMMdd"));
int age = (now-dob) / 10000;
Response.Write(age);
%>
But I am getting invalid argument error. What am I doing wrong?