Issue with 'Time'

Hello,

I have used time function in the XLS form to record the time when respondent is available in their home. The output I get is in ‘02:15:00.000-04:00’ format instead of ‘02:15’ . What do all the other digits in the time represent? How can I get XLS form to show just HHMM (02:15.') in 24 hour clock.

(See


)
( See )

These are basically the time components of ISO 8601 formatted dateTime string used to store dates and times in the XForms. For more than you really want to know about date formats, see ISO 8601 - Wikipedia

Briefly, the format looks like: YYYY-MM-DD'T'HH:MM:SS:sss+TZ

where:

YYYY = 4 digit year
MM = 2 digit month
DD = 2 digit day
T = the ‘T’ character always separates the date from time components
HH = 2 digit hour (24-hour time)
MM = 2 digit minute
SS = 2 digit seconds
.sss = milliseconds (sometimes absent…)
+TZ = timezone info (may be -TZ depending on how the timezone is specified)

The time widget basically strips off the all date info before the ‘T’.

Please note, as described here, you need to be a bit careful when using the time question type because it may subsequently be displayed an hour off (!):

The time widget stores the time along with a time zone. This can cause unexpected behavior around Daylight saving time.

For example, if you record a time before the clock change, and then view the time after the clock change, it will appear to be an hour off. This happens because the recorded time data is understood as a specific moment in time that is being “translated” into your current, local time zone.

1 Like

If you just want the hours and minutes you can extract the necessary prefix string using the substr() function. Have a play with this:

Screenshot 2024-08-22 at 10.34.25 AM

FormatTime.xlsx (14.3 KB)

1 Like

Thank you so much.

1 Like