Skip to main content

age - script and chart function

The age function returns the age at the time of timestamp (in completed years) of somebody born on date_of_birth.

Syntax:  

age(timestamp, date_of_birth)

Can be an expression.

Return data type: numeric

Arguments:  

Age arguments
Argument Description
timestamp The timestamp,or expression resolving to a timestamp, up to which to calculate the completed number of years.
date_of_birth Date of birth of the person whose age is being calculated. Can be an expression.

Examples and results:  

These examples use the date format DD/MM/YYYY. The date format is specified in the SET DateFormat statement at the top of your load script. Change the format in the examples to suit your requirements.

Example 1:  

age('25/01/2014', '29/10/2012')

Returns 1.

Example 2:  

age('29/10/2014', '29/10/2012')

Returns 2.

Example 3:  

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.

Employees:

LOAD * INLINE [

Member|DateOfBirth

John|28/03/1989

Linda|10/12/1990

Steve|5/2/1992

Birg|31/3/1993

Raj|19/5/1994

Prita|15/9/1994

Su|11/12/1994

Goran|2/3/1995

Sunny|14/5/1996

Ajoa|13/6/1996

Daphne|7/7/1998

Biffy|4/8/2000

] (delimiter is |);

AgeTable:

Load *,

age('20/08/2015', DateOfBirth) As Age

Resident Employees;

Drop table Employees;

 

The resulting table shows the returned values of age for each of the records in the table.

Example 3 results
Member DateOfBirth Age
John 28/03/1989 26
Linda 10/12/1990 24
Steve 5/2/1992 23
Birg 31/3/1993 22
Raj 19/5/1994 21
Prita 15/9/1994 20
Su 11/12/1994 20
Goran 2/3/1995 20
Sunny 14/5/1996 19
Ajoa 13/6/1996 19
Daphne 7/7/1998 17
Biffy 4/8/2000 15

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com