Saturday, October 20, 2007

How Do You Make A Kilt

ASP - ASP Script to calculate the age of a person! Again

Hello everyone!

Given that, on dates between the 1000000 functions present in the ' asp, there is a specific function to calculate the age of a person properly taking into account also the birthday of the latter, here I show a small function

Function calcolaeta ( BirthDate date)
'calculation of the years you have to make the user
eta = datediff ("yyyy " BirthDate date)
'calculation on the birthday of the current user
birday = dateadd ("yyyy , age, DoB )
'takes account of the day!
if datepart ("y", date) < datepart ("y", birday )
then age = age-1
end if
calcolaeta eta =
End Function

The function you have to pass two parameters, date of birth and date (eg today's) for which we know the age!
The function returns a number that corresponds to the age correct!

In developing this little feature, I realized that I was doing just as we would have had trouble getting the correct age if the year was a leap year (could be wrong calculation of a day) then if it seems strange I've done what I did take note that too!
If you still seem strange to me that you probably have not made the choice easy and fast!
Illuminatemi!

If you are interested in the script here zipped !


Hello and see you soon!