Solved

CALCULATE AGE OF PERSON FROM DOB INPUT

Posted on 2004-04-07
2
1,189 Views
Last Modified: 2008-03-04
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
Comment
Question by:pjordanna
2 Comments
 
LVL 11

Accepted Solution

by:
Slimshaneey earned 500 total points
ID: 10773607
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 Comment

by:pjordanna
ID: 10773866
Slimshaneey,


Perfect!



PJORDANNA
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
is this a cms? 8 69
MS SQL 2008 and stored prodcures and dates 5 25
Validating Date 4 28
Prevent certain words from being typed in a form 6 24
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question