Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
bvmike2001
New Contributor

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
MVP
MVP

Re: timestamps difference in hours

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
New Contributor

Re: timestamps difference in hours

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

MVP
MVP

Re: timestamps difference in hours

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

Community Browser