• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1223

# CALCULATE AGE OF PERSON FROM DOB INPUT

Hi experts,

I need a quick classic ASP formula to calculate a persons age as of todays date (whatever that may be) based on a DOB input captured in the following format:

3 drop down boxes as follows:

dobDay (1-31), dobMonth (1-12), dobYear(1900-2004)

Thanks,

PJORDANNA

0
pjordanna
1 Solution

Commented:
function getAge(dtDOB)
dim iAge, dtTmp, dtToday
dtToday = Date()
iAge = CInt(DateDiff("yyyy",FormatDateTime(dtDOB,1),Date()))
dtTmp = CDate((Day(dtDOB) & "/" & Month(dtDOB) & "/" & Year(Date
())))
if (dtTmp > Date) then iAge = iAge - 1
getAge = iAge
end function

dim DOB
DOB = "15/01/1974"

Response.Write " 1. DoB is " & DOB
Response.Write " <BR>2. Age is " & getAge(DOB)
0

Author Commented:
Slimshaneey,

Perfect!

PJORDANNA
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.