Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
bvmike2001
Contributor III
Contributor III

timestamps difference in hours

Hello,

how can i calculate two timestamps difference in hours form two timestamp fields F1 and F2?

Many thanks!

3 Replies
swuehl
MVP
MVP

If your timestamps are correctly interpreted by QV, i.e. have a numerical representation, you should be able to just use:

=interval( F1 - F2, 'hh')

bvmike2001
Contributor III
Contributor III
Author

How can i test if my timestamps fields are correctly interpreted by QV?

swuehl
MVP
MVP

An indication is the correct label if you hover your mouse over the field in table view (CTRL-T). It should say timestamp, numerical (etc).

Then, by default the field values will be differently aligned (right) than pure text values (left).

If you use num(FIELD), you get the numerical representation returned, a number. If you use text(FIELD), you get the textual representation.

A QV timestamp is a dual and should have both representations (the numerical representation is the reason you can use numerical operators like +,- on timestamps or dates).

If your field is not correctly interpreted, use a correct standard format setting in your script

SET DateFormat='M/D/YYYY';

SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';

or use the QV functions timestamp#() resp. date#() to interpret your input values. Please check these functions and the date and time format codes.

There was also recently a nice blog entry by Henric Cronstroem explaining all this in detail.

Regards,

Stefan