The AGE function calculates the number of years between the current date (as determined by the system clock) and the value of the Date variable you specify.
The most common use of the AGE function is to find a person's current age from a date of birth, but you could use it to find out how long someone has been employed with the company, how long ago a trial was held, etc. The date value you provide can be in the form of a Date variable, a computation that produces a date value, or a literal date value.
Function name |
AGE |
Usage model | AGE( d:DATE ) |
Parameters | This function requires you to replace only one parameter: |
d: DATE |
The function evaluates the number of years between the current date and this specified date value. |
Result | A number value. |
While filling in court documents, a paralegal needs to know whether the defendant is a minor, because if he is, the documents also need to include parent or guardian information.
In the template, there is a Date variable called BirthDate where the end-user must select the defendant's date of birth during the interview. The template author can use this variable to find the defendant's age. In a new computation, the author first uses the AGE function to find the defendant's age by writing the following expression at the Script tab:
AGE ( BirthDate )
On its own, this computation would return a number value (the defendant's age). However, in this case, the author doesn't need to place the age into a document; instead, the age will be used to know which dialogs to include in the interview. To do this, the AGE expression is surrounded with an IF instruction, which checks if the defendant's age is less than 18. If the defendant is under 18, an ASK instruction is used to include a dialog called Parent-Guardian Information in the interview:
IF AGE ( BirthDate ) < 18 ASK Parent-Guardian Information END IF
Now in the interview, if the template user enters a date of birth indicating the defendant is under 18 years old on the current date, the Parent-Guardian Information dialog appears next in the interview; otherwise, if the defendant is 18 years or older, the Parent-Guardian Information dialog is not included as its questions are irrelevant.
After you download the example template, you can import the template to any workspace to see this example code in action.