Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
08748190
New Contributor II

Difference between to dates in years and months

Hello everyone,

I want to get the difference between two dates in year and month in my case i want mesure the seniority of salary

x by calcul the diffence between current date and hiring date. i used the function AGE to retourn the diffence.

For exemple: AGE(05/08/2019-05/04/2016) retourn 3 but i want to get 3,4 (years+months).

My question is how i get the diffence between two date in years and months ? thank you in advance.

1 Solution

Accepted Solutions
Partner
Partner

Re: Difference between to dates in years and months

Hi,

You can try:

Floor( (DateEnd-DateStart) / 365) 
+ 
(
 (
   (DateEnd-DateStart) / 365) - Floor( (DateEnd-DateStart) / 365)
  )
 / (365-12)
)

It's not a beautiful formula, but its exactly giving you the years and months.

Jordy

Climber

Work smarter, not harder
4 Replies
Partner
Partner

Re: Difference between to dates in years and months

Hi,

You can try:

Floor( (DateEnd-DateStart) / 365) 
+ 
(
 (
   (DateEnd-DateStart) / 365) - Floor( (DateEnd-DateStart) / 365)
  )
 / (365-12)
)

It's not a beautiful formula, but its exactly giving you the years and months.

Jordy

Climber

Work smarter, not harder

Re: Difference between to dates in years and months

Maybe like this

=Age(MakeDate(2019,08,05),MakeDate(2016,04,05))&','&Mod(Floor((MakeDate(2019,08,05) - MakeDate(2016,04,05))/30.4),12)

Frank_Hartmann
Honored Contributor II

Re: Difference between to dates in years and months

maybe like this:

=date(interval(date#('05/08/2019','DD/MM/YYYY')- date#('05/04/2016','DD/MM/YYYY')),'YY-MM')
08748190
New Contributor II

Re: Difference between to dates in years and months

Thank you