Elapsed Time

Recently we did a review of the searches that have been entered into our website and noticed that someone was searching the site using the words “Elapsed Time”. When we saw this we assumed they were looking for a way to work out how long a survey has taken. So in this article we will look at some of the things that you can do record how long a survey takes. First off when an interview is started, the system being used be it Data Entry , Web , Cati or mobile stores the date and start time in a field called “Datacollection.StartTime” and when the interview is no longer active the finish date and time gets stored in a variable called “Datacollection.finishTime”. So to work out the total interview time all you have to do is to take the start time away from the finish time and you will get your answer. But how do you do this , well the best way is to use a command called datediff. A good way to see how datediff works is to open up your data in dmquery and then use this syntax on it.

select datacollection.starttime,datacollection.finishtime , datediff(datacollection.starttime,datacollection.finishtime,'s') as SurveyDuration  from vdata

what this syntax does is to give us three columns of data , the fist is the start time followed by the finish time and then the difference between the two in seconds. As you can see the datediff command requires both dates and then a value to tell it what to return , in our example we wanted seconds , but you can have any of these values.

“yyyy” Calendar years
“q” Calendar quarters
“m” Calendar months
“d” Day
“y” Day of year (same as “d”)
“w” Week (seven-day periods)
“ww” Calendar weeks (using first-day-of-week setting from input locale)
“h” Hour
“n” Minute
“s” Second

So that is how we work out the time in DMQuery , but how about if we wanted to do it in a DMS script so that the result is saved. Well first off we need a question to hold the answer in this example we are going to use a long as that is the datatype returned by DateDiff().

SurveyDuartion "Survey Duartion" long;

and then in our onnext case event we would have something like

SurveyDuartion = datediff(datacollection.starttime,datacollection.finishtime,'s')

So that is how we work out the full survey duration , but what if we want to record how long it takes to answer a set of question in the survey. This is really easy , just create the metadata to hold the information,

Section1Duartion "Survey Duartion" long;

and then at the start of the section store the section start time in a variable and at the end of the section work out the difference, for example,

Dim Section1StartTime


Section1StartTime = now()

... The Section Questions 

Section1Duartion = datediff(Section1StartTime ,now(),'s')

And there you have it some simple

 to get the numbers that you need. So if it was you that searched for this type of info on our website the hopefully this has helped, but if not let us know what you where after and we get the info to you. It does not hurt to ask.

3 thoughts on “Elapsed Time”

  1. While this is a very useful solution for only those interviews that are completed in one setting. Interviews that are completed partially, then stopped, and resume on a different date and then completed will show a very long interview time. For example, if I started a survey on 1/1/2011 and stopped half-way through, then resume the survey and completed it on 1/3/2004, the elapsed time would show up as 72 hours. To get around this, I recommend creating a variable (if using sample management) in your sample management that captures the elapsed time every time the interview is stopped (or when completed). Each time the survey is stopped, the elapased time should then be updated in the sample management table by adding the previous value from the sample management field to the current elapsed time. Only when the interview is completed sucesfully should this value be written to the case data. This will give a much more accurate picture of elapsed time if users are stopping surveys.

  2. There is a topic about this in the v6 DDL, which is named as ‘Calculating the Total Time Taken to Complete Interviews’. This topic gives an example of how to calculate the total time taken to complete an interview, excluding time between any stops and restarts of the interview. Hope this helps.

Leave a Comment

%d bloggers like this: