highv0ltage
06-04-2004, 10:30 AM
I am trying to construct a script that will take someone's birthdate, compare it to today's date and calculate the person's age. Here's what I have so far:
birthday = request.form("bday")
birthmonth = request.form("bmonth")
birthyear = request.form("byear")
strDOB = birthday & "/" & birthmonth & "/" & birthyear
DOB = CDate(strDOB)
iAge = CInt(dateDiff("yyyy",DOB,now()))
IF (DOB < now()) THEN
iAge = iAge - 1
END IF
age = iAge
This doesn't seem to work entirely correct. Can anyone help me out? Thanks.
It just seems to determine the age by the year and doesn't take into consideration whether or not the person was born before or after todays month and day.
birthday = request.form("bday")
birthmonth = request.form("bmonth")
birthyear = request.form("byear")
strDOB = birthday & "/" & birthmonth & "/" & birthyear
DOB = CDate(strDOB)
iAge = CInt(dateDiff("yyyy",DOB,now()))
IF (DOB < now()) THEN
iAge = iAge - 1
END IF
age = iAge
This doesn't seem to work entirely correct. Can anyone help me out? Thanks.
It just seems to determine the age by the year and doesn't take into consideration whether or not the person was born before or after todays month and day.