Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Why is my age function not working?


Hi all,

New enought to QV but I am trying to use the age functio to as per below but I am getting nothing in return, nay ideas why?

 

AGE('01/sep/2014',IND_BIRTH_DT)/12 as age_at_sep14

Thanks,

Aidan

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Why is my age function not working?

Try putting the date as 2014-09-01 format. so the expresssion would be as follows:

AGE('2014-09-01',IND_BIRTH_DT)/12 as age_at_sep14

7 Replies

Re: Why is my age function not working?

It seems that your values within the age() won't be recognize as date-values. For this you could use date, date# or num, num# to format/convert your values.

- Marcus

Not applicable

Re: Why is my age function not working?

Try putting the date as 2014-09-01 format. so the expresssion would be as follows:

AGE('2014-09-01',IND_BIRTH_DT)/12 as age_at_sep14

Not applicable

Re: Why is my age function not working?

Hi,

Thanks but unfortunately this has not worked for me

Here is a few more things I have tried;

 

AGE(num#('01/aug/2014'),num#(IND_BIRTH_DT))/12 as age_at_aug14,
AGE(date(('01/sep/2014')),date(IND_BIRTH_DT))/12 as age_at_sep14,
AGE('2014-10-01',(IND_BIRTH_DT)/12) as age_at_oct14

Cheers,

Aidan

Not applicable

Re: Why is my age function not working?

 

AGE(num#('01/aug/2014'),num#(IND_BIRTH_DT))/12 as age_at_aug14,
AGE(date(('01/sep/2014')),date(IND_BIRTH_DT))/12 as age_at_sep14,
AGE('2014-10-01',(IND_BIRTH_DT)/12) as age_at_oct14

sebastiandperei
Valued Contributor

Re: Why is my age function not working?

Hi. I don't know what you have in IND_BIRTH_DT, also, i don't know which one is your date standard format....

So, you can try with:

Age ( Date(Makedate(2014,09,01)), Date(Date#(IND_BIRTH_DT)))

To test this before do reload, select a value in IND_BIRTH_DT and put the above function in a TextBox. It should return the number of years. The most important is the format of IND_BIRTH_DT field. If the last doesn't work, please, go to tables (Ctrl+T), right click on the table that contents this fields, and tell us exactly the format of the values in the field, and if it is right of left arranged.

Also, AGE() will return an integer with the number of years. About the "/12" of your function, i guess you need the number of months. For do that, tell us how much months you need to show between these dates:

20/Jan/2014 - 15/Apr/2014: 2 or 3 months?

datagrrl
Contributor III

Re: Why is my age function not working?

Okay, I am new at this, so maybe I overdid it, but this worked for me:

AGE(DATE(DATE#('01/sep/2014','DD/MMM/YYYY'),'MM/DD/YYYY'),DATE(IND_BIRTH_DT,'MM/DD/YYYY'))

As for the /12 I am not sure what you are trying to get here. It would be one for every 12 years. If you want rough months you could do *12.

It could be some internal measure I don't understand, if so you should be able to tack it onto the above.

Not applicable

Re: Why is my age function not working?

Hi

The below worked when removed the /12, it was something I carried over from SQL

Thanks for all replies

 

AGE('2014-10-01',IND_BIRTH_DT) as age_at_oct14,

Community Browser