Home > FAQ, How To's > How To Measure Time Between Questions?

How To Measure Time Between Questions?

Overview

This how-to will show you how to measure time differences between parts in your survey.
Time differences can be given in most of the common time formats seconds, minutes, etc’.

How To Do It?

In the place where you want to tick the start time you can use the following code:
Vars[“Start”]=Now;

This will capture the current time & date within a global variable that I called it “Start” (Can call it whatever you like).

Then, in the place you want to capture the end time & date, you should use the following code:
Vars[“End”]=Now;

*Note: These code lines would be best written within start\end scripts.

Now, all that’s left to do, is to check the time difference we want, here are the functions optional for it:

TimeDiffYears(Vars[“End”],Vars[“Start”]);

TimeDiffMonths(Vars[“End”],Vars[“Start”]);

TimeDiffDays(Vars[“End”],Vars[“Start”]);

TimeDiffHours(Vars[“End”],Vars[“Start”]);

TimeDiffMinutes(Vars[“End”],Vars[“Start”]);

TimeDiffMilliSeconds(Vars[“End”],Vars[“Start”]);

TimeDiffSeconds(Vars[“End”],Vars[“Start”]);

Each will return a numeric value which corresponds to the difference in the given time format.
You can return this value in an expression question, or even use it for rules and scripts!

Example

In this example, all I did is capture the time taken for Question 1:

And created an entrance rule for question 2, so it would enter it only if the difference was greater than 10.

The time representation/format may very between different devices. If you want the time difference to be formatted the way you want it to be you can use the following function:  FormatNumber(numberToFormat, digitsAfterDecimalPoint, toRound);

Below you can find few examples:

FormatNumber (203.4675, 1, false) will return 203.4
FormatNumber (203.4675, 1, true) will return 203.5
FormatNumber (203.4675, 2, false) will return 203.46

That’s it!

Visit us at: http://www.dooblo.net

Categories: FAQ, How To's
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: