Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ryan_evans1984
Contributor
Contributor

Calculate the difference in seconds between two time stamps.

I have used a resident load group by with in my code and I cannot calculate the correct duration in seconds between the start timestamp and end time stamp

Current_Data:

Load

datStart,

datEnd,

""Looking for a line to calculate the difference between datStart & datEnd ******

MachineName as L_Machine_Name

RESIDENT Data

Group by MachineName;

8 Replies
Anil_Babu_Samineni

There is no aggregate here, Not sure why you required Group By? Perhaps this.

Current_Data:

Load

datStart,

datEnd,

Interval(datStart-dayEnd,'hh:mm:ss') as NewField,

MachineName as L_Machine_Name

RESIDENT Data

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vishsaggi
Champion III
Champion III

Can you tell us the date format your fields has.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Assuming datEnd and datStart are timestamps, the differences in seconds would be:

num(interval(datEnd-datStart, 's'))

You may perhaps not want the actual seconds, but rather keep the standard duration (1 = 1 day) and instead just display the value as seconds.

interval(datEnd-datStart, 's')


-Rob

ryan_evans1984
Contributor
Contributor
Author

Thanks  for the comments.

I created a group by because I wanted a small table by machine... the main table 'data' has 800k rows.

I just wanted to show the last datstart and datend by machine in a small table.

ryan_evans1984
Contributor
Contributor
Author

Thanks  for the comments.

I created a group by because I wanted a small table by machine... the main table 'data' has 800k rows.

I just wanted to show the last datstart and datend by machine in a small table.

ryan_evans1984
Contributor
Contributor
Author

Thanks for the comments.

The num(interval(datEnd-datStart, 's')) works and displays a number but I wanted seconds.


And the interval(datEnd-datStart, 's') doesnt work.


tried multiple things and still cannot get this into seconds.


rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I typed too fast.

interval(datEnd-datStart, 's')


should display the value in seconds. What does it display for you?


-Rob

balabhaskarqlik

May be:

=sum(datEnd-datStart) * 24 * 60 * 60