Time Difference
Time Difference
Dear all
I would like to calculate time difference of STARTING & END of interview.
I'm using auto calculation of time from system.
Starting time
preproc
START=int(systime()/1);
End time
preproc
END=int(systime()/1);
Interview time taken ??
Thank you.
I would like to calculate time difference of STARTING & END of interview.
I'm using auto calculation of time from system.
Starting time
preproc
START=int(systime()/1);
End time
preproc
END=int(systime()/1);
Interview time taken ??
Thank you.
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Time Difference
You are better off using the timestamp function for things like this. It returns the number of seconds since 1970, which means that subtracting the end timestamp from the beginning timestamp gives you the total time (in seconds).
Using systime is tricky because you would have to convert the time into a value that can be used in a subtraction operation. I think there are examples on the forum of doing this, but I would stick with timestamp.
Using systime is tricky because you would have to convert the time into a value that can be used in a subtraction operation. I think there are examples on the forum of doing this, but I would stick with timestamp.
Re: Time Difference
Hi Gregory Martin
Thank you for your timely reply.
I can't find much about timestamp or couldn't understand much. What should be the length in the dict.
If possible can you elaborate with an example.
Sorry for the inconvenience. Thank you.
Thank you for your timely reply.
I can't find much about timestamp or couldn't understand much. What should be the length in the dict.
If possible can you elaborate with an example.
Sorry for the inconvenience. Thank you.
Re: Time Difference
Look at the example in the help for timestamp: http://www.csprousers.org/help/CSPro/ti ... ction.html
Put that logic in the preproc of the questionnaire. SURVEY_DURATION will be the time in seconds.
Put that logic in the preproc of the questionnaire. SURVEY_DURATION will be the time in seconds.
Re: Time Difference
Hi Josh and Gregory Martin
I'm very sorry and my apologies beforehand.
I have tried the timestamp(), however couldn't get the result.
I'm attaching the file where you can checked and clear my doubts.
Thank you and sorry for the inconvenience.
I'm very sorry and my apologies beforehand.
I have tried the timestamp(), however couldn't get the result.
I'm attaching the file where you can checked and clear my doubts.
Thank you and sorry for the inconvenience.
-
- Posts: 573
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
Re: Time Difference
Please use this code
Best.
a.
Code: Select all
PROC START
Preproc
$=timestamp();
PROC END_TIME
preproc
END_TIME =timestamp();
PROC DURATION
Preproc
DURATION = End_time-Start;
a.
Re: Time Difference
The timestamp() function gives you the time at the moment that you call it so you want to call it once to get the start time at the beginning of the form and then call it again at the very end of the form. That will give the start and end times. Then you can subtract the start from the end to get the duration.
So you need to put the variable START at the beginning of the questionnaire and set START=timestamp() in the proc for START. Then set END_TIME=timestamp() in the END_TIME PROC at the end of the form. Finally calculate the duration at the end of the questionnaire by setting it equal to END minus START.
Currently you are setting START to timestamp() inside the proc for DURATION and then getting the end time and calculating the difference all the in DURATION proc. This is always going to be too small since you are going to get the time spent inside that field.
So you need to put the variable START at the beginning of the questionnaire and set START=timestamp() in the proc for START. Then set END_TIME=timestamp() in the END_TIME PROC at the end of the form. Finally calculate the duration at the end of the questionnaire by setting it equal to END minus START.
Currently you are setting START to timestamp() inside the proc for DURATION and then getting the end time and calculating the difference all the in DURATION proc. This is always going to be too small since you are going to get the time spent inside that field.
Re: Time Difference
Hi Josh and khurshid.arshad
Thank you for your timely reply.
I have written the same however it is showing ******* in the variables.
I have given 6 length (numeric) in start and end time. And 5 length (numeric) in duration time.
Am I doing something wrong.
Thanks.
Thank you for your timely reply.
I have written the same however it is showing ******* in the variables.
I have given 6 length (numeric) in start and end time. And 5 length (numeric) in duration time.
Am I doing something wrong.
Thanks.
-
- Posts: 573
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
Re: Time Difference
variable length not matched with timestamp. Please increase variable length till 10.
Best.
a.
Best.
a.