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

Getting wrong answer

hi

  In my chart I am trying this expression to get product age

timestamp(Date(today()) - Date(poentrydate), 'Y') * 12 + timestamp(Date(today()) - Date(poentrydate), 'M')

so that i will get age in months .

but using above expression getting high values .. y? can someone help me?

also when i just use

timestamp(Date(today()) - Date(poentrydate), 'Y')

i am getting right answer adding multilplying getting big values


1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

What you need is:

(Year(Today()) - Year(poentrydate)) * 12 + Month(Today()) - Month(poentrydate)

Hope that helps

Jonathan

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

View solution in original post

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

What you need is:

(Year(Today()) - Year(poentrydate)) * 12 + Month(Today()) - Month(poentrydate)

Hope that helps

Jonathan

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

i wrote same expression before and guess what i was not seeing anything so i thought i am not getting answer

but my window was small and answer was coming but i had to scrollll ..  wasted so much time..

Thanks Jonathan

Not applicable
Author

Can you just explain why i was getting big numbers???

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Because timestamp(.., 'Y') does not convert the date to a year number - it formats it to display only a year number, but is internally unchanged. Therefore you were mutliplying a date number (a number of about 41000) by 12. The same applies to timestamp(..., 'M').

The correct way to convert the values are the Year and Month functions.

Regards

Jonathan

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

thank you Jonathan