Date time variable for computing interview duration for every module

Dear Sergiy,

Am Oganga Caneble from Kenya National Bureau of Statistics, we used Survey Solutions to Conduct a Survey in which we intended to calculate the interview duration for every module in the survey. To achieve this, the questionnaire had a start time and end time for each module.

Therefore, am using Stata to analyse the data, and my challenge is in the splitting of the time variable, for instance, the Survey Solutions recorded time, “2020-04-23T09:36:21” to compute interview duration.

Kindly share a Stata Code that calculates the duration in Hours, Minutes and Seconds.

Hello Oganga Caneble,

Stata’s function clock() may be used to convert date and time information from string presentation to numeric. It is described here:

For example:
display %25.0g clock(subinstr(“2020-04-23T09:36:21”,“T”,"",.), “YMDhms”)