Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rittermd
Master
Master

calculate date based on future age

Here is my challenge.

I have a DOB for a client.  I need to calculate the correct date based on their future age.  For example person is born on 12/31/1975.  I need to know the future date when they turn 12 years and 6 months old.

I tried just adding 150 months to their DOB.  That works most of the time.  But in this example it doesn't work because it put the date in June that only has 30 days.  So my calculation will show June 30 1987.  It should actually show a day in July.  So just adding months does not take into account the number of days in each month.

What can I do?

3 Replies
Anonymous
Not applicable

Hi,

Maybe add/minus 1 day if number of days in a month is not equal to number of days in a future month.

Regards

Neetha

robert_mika
Master III
Master III

Did you try

=AddMonths('31-2-1975',150)

hic
Former Employee
Former Employee

Depends on what you mean by 12 years and 6 months.

"A month" could mean the number of days the actual calendar month has, and then you should use AddMonths(). But it could also mean e.g. the average month length: 30,43687 days. Similarly, "a year" could be the number of days the calendar says, or it could be 365,2424. (Adding days is simple. Just use Date + <NumberOfDays>.)

So, just saying 12 years and 6 months is ambiguous.

You need to define what you mean, and then use a combination of adding years using AddYears(), adding months using AddMonths(), and adding days using simple addition.

HIC