Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Gartner® Magic Quadrant™: 15 YEARS A LEADER - GET THE REPORT
cancel
Showing results for 
Search instead for 
Did you mean: 
New-here1
Contributor III
Contributor III

Date and Time Difference

Hi, 

I have 2 columns in my table that are both shown like this:

Date 1 - dd/mm/yyyy hh:mm:ss 

Date 2 - dd/mm/yyyy hh:mm:ss

I want to show the difference between the two so that I can see how long it has been with a person but everything I try, nothing seems to work. Any ideas please?

 

Labels (2)
6 Replies
Eloi
Contributor II
Contributor II

Hello,

Maybe you should try that solution : 

Interval(Timestamp#([Date2], 'DD/MM/YYYY hh:mm:ss') -Timestamp#([Date1], 'DD/MM/YYYY hh:mm:ss'), 'd hh:mm:ss')

Have a nice day,

New-here1
Contributor III
Contributor III
Author

Sadly interval didn't work

 

New-here1
Contributor III
Contributor III
Author

unfortunately, interval doesnt work. The result just comes back with nothing 

 

PREMinQLIK_DBS2
Contributor II
Contributor II


in @Eloi reply use trim if in case raw column is string ( you can verify calling fields -list box  in sheet or in preview , String values will be aligned left side , where as date and numeric values will align rightside).

Interval(Timestamp#([trim(Date2]), 'DD/MM/YYYY hh:mm:ss') -Timestamp#([trim(Date1]), 'DD/MM/YYYY hh:mm:ss'), 'd hh:mm:ss')

Vegar
MVP
MVP

Hi @New-here1 

Using Interval(value2-value1), as suggested by@BPiotrowski , @Eloi and @PREMinQLIK_DBS2 , will be the best way forward. 

You bet blank/null values because Qlik does not recognise the two fields as timestamps.

  • Make sure that you are able to load your [Date 1] amf [Date 2] fields as timestamps. That could be done in the script or in the measure. Using timestamp#() is a feasable way in both cases.
  • When you have made sure that both fields are recognised as timestamps,  then you can subtract one from the other to get an interval . Wrap interval() around that expression to get a user readable format.

If you have issues getting the Date fields into timestamp formats then please add additional information on how the timestamps are created in the script. And which steps you have tried to solve your issue.