Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Date diff compute year

How can i do to make the year difference from 2 dates? I need it to compute the age.

Marco

1 Solution

Accepted Solutions
Highlighted

There is an "Age" function that does exactly this:

     Age(timestamp, date_of_birth)

HIC

View solution in original post

14 Replies
Highlighted
Not applicable

You should be able to use FABS(Year(Date1)-Year(Date2))

FABS will give you the absolute value so it doesn't matter which way around the dates are.

Highlighted
Anonymous
Not applicable

year(date1)-year(date2)+1 (( +1 depending what result you expect for same year (0 or 1)

or not that what you want? then specify more your requirements

Highlighted
Master III
Master III

Interval function will help you out

Interval(Date1-Date2,'DD')

Highlighted
Partner
Partner

Hi,

Try this:

DATA:

LOAD

  *,

  if(month(DeadDate)<month(BornDate),year(DeadDate)-year(BornDate)-1,year(DeadDate)-year(BornDate)) as "Age"

Inline [

BornDate, DeadDate

01/10/1950, 02/05/2015

01/01/1960, 03/08/2015

];

Highlighted

There is an "Age" function that does exactly this:

     Age(timestamp, date_of_birth)

HIC

View solution in original post

Highlighted
Partner
Partner

Ok with year we can approximate the age from now.

Thanks

Marco

Highlighted

If you need a more accurate age:

    Floor((Date1 - Date2) / 365.25)

     or

    Ceil((Date1 - Date2) / 365.25)

     or

    Round((Date1 - Date2) / 365.25, 0.1)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Highlighted
MVP
MVP

Use this...

Reference

swuehl
Highlighted
Master II
Master II

use Interval() ,if u need u can specify format as well with the function.