Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
tresB
Champion III
Champion III

Age Calculation

Hi all,

I have two date fields(Joining Date, Today()). I want to calculate the time span for how long the person is with the company, i.e. the time duration in the form of- ?? Years ??Months and ??days.

Is there any simple formula that can help? or i will have to do it manually(getting the difference in days and then divide it by 365......)?

Thanks and regards,

tresesco

Labels (1)
1 Solution

Accepted Solutions
Miguel_Angel_Baeyens
Support
Support

Hello Tresesco,

For just years, you can use

=Age(Date(Today()), Date('01/01/2008'))


Days

=Num(Date(Today()) - Date('01/01/2008'))


The whole

=timestamp(Date(Today()) - Date('01/01/2008'), 'YY MM DD hh:mm:ss')


Hope that helps!

View solution in original post

7 Replies
Not applicable

Hi Tresesco,

I think you can use as following

age(today(),Joining Date) as duration

Regards,

Nilupa

Miguel_Angel_Baeyens
Support
Support

Hello Tresesco,

For just years, you can use

=Age(Date(Today()), Date('01/01/2008'))


Days

=Num(Date(Today()) - Date('01/01/2008'))


The whole

=timestamp(Date(Today()) - Date('01/01/2008'), 'YY MM DD hh:mm:ss')


Hope that helps!

tresB
Champion III
Champion III
Author

Thanks Baeyens,

your timestamp function has given me the solution:

Finally i used Variable1 =timestamp(Date(Today()) - Date('DateOfJoining'), 'YY MM DD hh:mm:ss')

=left(Variable1,2)& ' Years ' & Mid(Variable1,3,2) &' Months '&Mid(Variable1,6,2)&' Days'

and i got the desired result.

thanks once again.







tresB
Champion III
Champion III
Author

Hi,

Though i thought that i got the solution, it was with a little error. The differences were coming one month+ error. For example: 1st jun 2010 - today() giving 3 months 27days

1st sep 2008 -today() giving 1 Year 12 Months 25 days

So I had to subtract 1 from the month manually. Does anybody have any explanation.....?

jonathandienst
Partner - Champion III
Partner - Champion III

Because timestamp(1, 'DD/MM') = 01/01 (1st Jan) and timestamp(32, 'DD/MM') = 01/02 (1st Feb). Same with date().

I think you just need to subtract 1 as you found out.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Hi i want to calculate an age from an ID number... Please advise

tresB
Champion III
Champion III
Author

can you please explain your scenario?

regards,  tresesco