Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Zaidan_as
Creator
Creator

Create a Field From Calculated the Date Difference Between Two Dates Data

Hello All,

As i mention in the Subject, I want to calculate the date difference between two dates data, then store it into new field. 
So my data basically like this

Zaidan_as_0-1647306833746.png

I want to calculate the difference between Closed Date and the Created Date in Day format, but it has decimal value. 

So for example, the first data, the created date is 10/16/2018 9:00:53 AM and the Closed Date is 10/22/2018 11:11:40 AM, then for the result, if I count in the Excel using this function :
Closed Date - Created Date
I got the result = 6,09 Days. 

I already tried this in the QlikSense :
Interval((date#(([Closed Date]),'MM/DD/YY hh:mm:ss')) - (date#([Created Date],'MM/DD/YY hh:mm:ss')),'d')
but the result is '-'.

Labels (5)
1 Solution

Accepted Solutions
Iswarya_
Creator
Creator

Try like this:

=num((date#(([Closed Date]),'MM/DD/YY hh:mm:ss TT')) - (date#([Created Date],'MM/DD/YY hh:mm:ss TT')),'##.00')

Iswarya__0-1647327862988.png

 

View solution in original post

4 Replies
Iswarya_
Creator
Creator

Hi @Zaidan_as ,

Try this:

Interval((date#(([Closed Date]),'MM/DD/YY hh:mm:ss TT')) - (date#([Created Date],'MM/DD/YY hh:mm:ss TT')),'d')

Zaidan_as
Creator
Creator
Author

Thanks for the answer,

Your expression working fine, but the result is integer. Can it change to the float, so the result is just like i write in the Post.

This is the result with your expression

Zaidan_as_0-1647325651134.png

I want the first data, from 6 to 6,09. 

But if it's cannot change to integer to float, it's ok for me.



Iswarya_
Creator
Creator

Try like this:

=num((date#(([Closed Date]),'MM/DD/YY hh:mm:ss TT')) - (date#([Created Date],'MM/DD/YY hh:mm:ss TT')),'##.00')

Iswarya__0-1647327862988.png

 

Zaidan_as
Creator
Creator
Author

Wow. It working really fine. Thank you so much for your answer.