Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
how to calulate time difference
sarathi87k,
is your question answered (because you set the status alike, but you posted and set the status to assumed at the same time, so I assume this was done by mistake)?
If not:
It's easy to calculate a time difference in qlikview.
1) take care that the two timestamps you want to calculate the time difference from are QV timestamps with a numeric representation (integer part represents days, decimals the fraction of a day). If needed, use timestamp#() function to interpret a string as a timestamp.
2) Just subtract your two timestamps:
=TIMESTAMP2 - TIMESTAMP1
3) Format the result as needed using interval() function, e.g.
=interval( TIMESTAMP2 - TIMESTAMP1, 'hh:mm')
[check format codes in the HELP for more details]
Hope this helps,
Stefan
Hi,
What should I do when the timestamp 1 is newer then the timerstamp 2 in a tabel?
This because both ways are possible in a tabel.
Example:
timestamp 2 - timestamp 1
10-03-2013 17:00 - 10-03-2013 08:00 result: 09:00 (h:mm)
10-03-2013 17:00 - 10-03-2013 18:00 result: -01:00 (h:mm)
What kind of expression I need to make this possible?
In these cases you better use conditional statement and do the substraction.
Hi,
You can try this
If(TIMESTAMP2> TIMESTAMP1,interval( TIMESTAMP2 - TIMESTAMP1, 'hh:mm'),interval(TIMESTAMP1-TIMESTAMP2, 'hh:mm'))
Hope this help.........
Thanks, this works good for me.
Only the I'll don't get a negative value, but that doesn't matter me.
You can use the fabs function to turn that negative value positive.