Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

milliseconds

Dear all,

is there a function in Qlikview to calculate milliseconds, like the function below:

sum(DATEDIFF (MILLISECOND , isnull(START_DATE,0) , isnull(END_DATE,0))) TIMEDURATION

Help please !!

Thanks in advance

Labels (1)
1 Solution

Accepted Solutions
MarcoWedel
MVP
MVP

multiplying an interval with 86400 (number of seconds per day) should suffice to get the intervall in seconds.

So your expression


ceil(num#(text(Interval(TIMEDIFF, 'hh')))*3600 + minute(TIMEDIFF)*60 + second(TIMEDIFF)) as SECONDS


simply becomes


TIMEDIFF * 86400 as SECONDS


To get the milliseconds, it would be just


TIMEDIFF * 86400000 as SECONDS


regards


Marco

View solution in original post

4 Replies
swuehl
Champion III
Champion III

Sorry, I don't get what you want.

Time calculations are just floating point operations, like

Time1 - Time2 as TimeDiff

in a load script to get the difference of field values (assuming Time1 and Time2 are correctly interpreted as time values).

You can format the Result using

Interval(TimeDiff,'hh:mm:ss.fff')

[where fff denotes the milliseconds]

Anonymous
Not applicable
Author

First of all, thanks for your replay.

I need to calculate the milliseconds.

I do this:

ceil(num#(text(Interval(TIMEDIFF, 'hh')))*3600 + minute(TIMEDIFF)*60 + second(TIMEDIFF)) as SECONDS

but I don't know how to calculate milliseconds

I hope I explained a bit better

MarcoWedel
MVP
MVP

multiplying an interval with 86400 (number of seconds per day) should suffice to get the intervall in seconds.

So your expression


ceil(num#(text(Interval(TIMEDIFF, 'hh')))*3600 + minute(TIMEDIFF)*60 + second(TIMEDIFF)) as SECONDS


simply becomes


TIMEDIFF * 86400 as SECONDS


To get the milliseconds, it would be just


TIMEDIFF * 86400000 as SECONDS


regards


Marco

MarcoWedel
MVP
MVP

like swuehl already said:

always remember that timestamps and intervals are just floating point numbers with the integer part being full days and the fraction being the hours, minutes and seconds.

regards

Marco