Qlik Community

Third-Party Qlik Jobs

Area for people to learn more about current Qlik related job postings.

Highlighted
govardhanareddy
New Contributor

I want to get the time Difference

I want to get the time difference 

how can i get it

i have Date&Time field like the below 

can any one help me

Date&Time
10/18/2018 9:30:00 AM
10/18/2018 9:50:00 AM
10/18/2018 9:56:00 AM
10/18/2015 9:57:00 AM
10/18/2018 10:08:00 AM
10/18/201810:17:00 AM
10/18/2018 10:20:00 AM
10/18/2018 10:23:00 AM
10/18/2018 10:24:00 AM
10/18/2018 06:57:00 PM
10/18/2018 06:58:00 PM
10/18/2018 06:59:00 PM
10/18/2018 07:00:00 PM
10/18/2018 07:01:00 PM
10/18/2018 07:02:00 PM
10/18/2018 07:03:00 PM
10/18/2018 07:04:00 PM
10/18/2018 07:05:00 PM
10/18/2018 07:07:00 PM

10/18/2018 07:08:00 PM

4 Replies

Re: I want to get the time Difference

Get time difference where?
jmmayoral3
Contributor

Re: I want to get the time Difference

Hello.

You can use the function Interval( A-B, 'D hh:mm' ).

where A is the newest date, B is the oldest date  and the thirth parameter is the format you has the result (Days, hours:minutes)

ckarras22
New Contributor III

Re: I want to get the time Difference

Hello,

I guess you want the difference between rows

Something like below is what you may want:

DT_TABLE:
LOAD
      [Date&Time],
      interval([Date&Time]-peek([Date&Time]),'D hh:mm') as timedelta
RESIDENT [Table]
order by [Date&Time]
;

 

/Christos K.

 

jmmayoral3
Contributor

Re: I want to get the time Difference

If you want to calculate the difference between one record and the previous record, do it in the script adding to each record a new field with the difference over the previous record.

Sort your table using your date field and use INTERVAL() and PREVIOUS() functions to add the new field.

Example: (imagine your date&Time field is called "Fecha")

NEW_TABLE:
LOAD * ,
Interval( Fecha - PREVIOUS(Fecha), 'D hh:mm' ) as difference
RESIDENT old_table
ORDER BY Fecha DESC

Community Browser