Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
Not applicable

TRACE elapsed timespan in a QVW script

Hi, I'm trying to the following in a QVW script, and am missing something in how I calculate the duration:

LET vStartTime = Now();

// [Do something that takes a few minutes]

LET vEndTime = Now();

LET vDuration = $(vEndTime) - $(vStartTime);  // SCRIPT ERROR

TRACE Elapsed time: $(vDuration);

I would have thought that Using TRACE to capture the Elapsed Reload time would have answered this question, but it's missing the timespan/duration/elapsed part.  I've tried using the Interval() function, but so far without success.


Can anyone correct this script?  Thanks.

1 Solution

Accepted Solutions
srchilukoori
Valued Contributor

Re: TRACE elapsed timespan in a QVW script

Try this :

LET vDuration = Interval(Timestamp#('$(vEndTime)') - Timestamp#('$(vStartTime)'), 'hh:mm:ss'); 

5 Replies
srchilukoori
Valued Contributor

Re: TRACE elapsed timespan in a QVW script

Try the script below.

LET vStartTime = Now();

// [Do something that takes a few minutes]

SLEEP  10000;

LET vEndTime = Now();

LET vDuration = Timestamp#('$(vEndTime)') - Timestamp#('$(vStartTime)'); 

TRACE Elapsed time: $(vDuration);

Not applicable

Re: TRACE elapsed timespan in a QVW script

Very close -- now just trying to format result in seconds...

srchilukoori
Valued Contributor

Re: TRACE elapsed timespan in a QVW script

Try this :

LET vDuration = Interval(Timestamp#('$(vEndTime)') - Timestamp#('$(vStartTime)'), 'hh:mm:ss'); 

Not applicable

Re: TRACE elapsed timespan in a QVW script

Perfect, thank you!

maykerreyes
New Contributor II

Re: TRACE elapsed timespan in a QVW script

Excellent!!!!