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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Age calculation

Hi,

I need to calculate the Age of the tickets. I have tried using the Age function and Networkdays. Since Age function gives the result in years and Networkdays gives the number of working days excluding the weekends i am not able to use the above functions... Is there any other way i can calculte the Age of the tickets.

Regards,xxx

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

If something was opened yesterday and closed today, do you want to say it was open for 1 day, or 2 days? If 1 day, use floor(CloseDate - OpenDate). If 2 days, use ceil(CloseDate - OpenDate). This isn't a question of accuracy. It is a requirements question, a question about what YOU want to see.

Edit: Wait, no, ceil() is wrong. If they're straight dates, you'll get 1 with both floor() and ceil(). If they're timestamps, you'll get 0 or 1 with floor(), 1 or 2 with ceil(). So for dates, it's just CloseDate - OpenDate or CloseDate - OpenDate + 1. For timestamps, probably daystart(CloseDate) - daystart(OpenDate) or daystart(CloseDate) - daystart(OpenDate) + 1. Mind you, if I had timestamps, and I wanted dates, I'd just create dates out of the timestamps, and then use the dates in the calculation. Or maybe you want straight timestamp calculations instead of date calculations. So many possibilities. Mainly I just wanted to point out that my answer was wrong.

View solution in original post

5 Replies
Miguel_Angel_Baeyens

Hello,

You can use interval() and format the output to show minutes, hours, days...

Regards.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you want to count all days, just subtract start from end like:

CloseDate - OpenDate;

You can format as whole number of days like

floor(CloseDate - OpenDate)

-Rob

Not applicable
Author

Thanks for your response Miguel A. Baeyens & Rob Wunderlich....

Hi Rob,

If i am going to use (CloseDate - OpenDate) or floor(CloseDate - OpenDate) . do i need to add +1 with result.Normally in Sql server if u are using datediff then +1 should be added to the result to get the accurate date diff...........

Regards,xxx

johnw
Champion III
Champion III

If something was opened yesterday and closed today, do you want to say it was open for 1 day, or 2 days? If 1 day, use floor(CloseDate - OpenDate). If 2 days, use ceil(CloseDate - OpenDate). This isn't a question of accuracy. It is a requirements question, a question about what YOU want to see.

Edit: Wait, no, ceil() is wrong. If they're straight dates, you'll get 1 with both floor() and ceil(). If they're timestamps, you'll get 0 or 1 with floor(), 1 or 2 with ceil(). So for dates, it's just CloseDate - OpenDate or CloseDate - OpenDate + 1. For timestamps, probably daystart(CloseDate) - daystart(OpenDate) or daystart(CloseDate) - daystart(OpenDate) + 1. Mind you, if I had timestamps, and I wanted dates, I'd just create dates out of the timestamps, and then use the dates in the calculation. Or maybe you want straight timestamp calculations instead of date calculations. So many possibilities. Mainly I just wanted to point out that my answer was wrong.

Not applicable
Author

Thanks for your clarification....

valid point we have to think about it.