This script is using two numeric questions to calculate the duration of the study ("qend" and "qduration").
//surveyscripting.com
//this part must be set in the beginning of the interview
var dateObj = new Date(InterviewStart());
if (!f('Dstart').toBoolean())
{
f("Dstart").set(dateObj);
}
//this part must be set in the end of the interview
var dateObj = new Date(InterviewEnd());
if (!f('Dend').toBoolean())
{
f("Dend").set(dateObj);
}
var diff = ((f('Dend').toNumber() - f('Dstart').toNumber())/60000);
f("qduration").set(diff);