Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Age Calculation Script error
06-10-2010, 03:20 PM #1
- Join Date
- Apr 2010
- Thanked 0 Times in 0 Posts
Age Calculation Script error
I am using the below code to calculate the age of a child from DOB. Criteria is as of 09/01/2010 (for the school year 2010-11). Even though the script seems to working fine in some cases the age calculations are wrong. Can some please tell what is wrong with the code.
For ex: DOB 12/20/1999 the age should be 10 as if 09/01/2010. However the age is calculated as 11 years.
Function Row_Inserting(rs) If Not EW_DEBUG_ENABLED Then On Error Resume Next DIM ChildAge, fromDate fromDate=CDate("09/01/2010") ChildAge = DateDiff("d",rs("DOB"),fromDate) If ChildAge <= (Cint("1095")) Then CancelMessage="Your child is too young to attend our classes. Please register after your child has reached pre-K." Row_Inserting = False Else rs("Age")= DateDiff("YYYY",rs("DOB"),Date()) Row_Inserting = True End If End Function
06-10-2010, 08:26 PM #2