AGE

ANSI DB2 SQL/DS XDB
      X

Calculates the difference in years between date1 and date2. The format appears below:

AGE(date1, date2)

For example, the query below retrieves the names of tasks begun less than 5 years as of TODAY:

SELECT task_name FROM tasks
WHERE AGE(startdate, TODAY) < 5

The AGE function also has a single parameter format that calculates the difference in years between today's date and date1. The format appears below:

AGE(date1)

The following query finds the age of each employee in the EMPLOYEE table.

SELECT lname, AGE(birth)
FROM employee