Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2010
    Posts
    57
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Age Calculation Script error

    Hi,

    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.

    Code:
    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
    Any pointers .. Thanks
    Vinny

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts
    Do you want a javascript answer?
    What you have posted is not javascript code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •