Format time to show hours and minutes only

commcare

I would like to format the time so that it is easily readable in a case list.

I am collecting the time of a follow-up appointment in 1 hour increments.

What is the right syntax to achieve this?

Is it better to format the time in a case list calculation or within the form?

Context:

Appointment time, is a time question.

The default for time is saved as 13:00:00.000-05

I want to use format-date to make the time information to appear as 13:00.

format-date(/data/appointment_time, '%H:%M') is not accepted.

Best Answer

format-date doesn't work for times, just for dates and datetimes. CommCare generally treats times like basic strings, so you can use substr: substr(appointment_time, 0, 5)

Related Topic