I have created a form in LiveCycle and want it to calculate a persons age as of a certain date once they enter their birthdate. How do I do this?
I have created a form in LiveCycle and want it to calculate a persons age as of a certain date once they enter their birthdate. How do I do this?
// compute age// get today's date in daysvar vEndDate = Date2Num(DateTimeField1[1].formattedValue, "MMM D, YYYY")// get DOB date in daysvar vStartDate = Date2Num(DateTimeField4[0].formattedValue, "MMM D, YYYY")// compute the difference in days age in daysvar vAgeDays = vEndDate - vStartDate// convert to whole yearsvar vAgeYears = Floor(vDiffDays / 365.25) // compute age for next dayvar vTestDay = vEndDate + 1// age in days for next dayvar vTestAge = vTestDay - vStartDate// age for next day in whole yearsvar vTestYears = Floor(vTestAge / 365.25)// compare ages in yearsif(vTestYears <> vAgeYears) then// some actionendif
Or you can use the JavaScript DateTime object to the various date properties and perform the appropriate computations
George Kaiser