Best way of displaying the time from a date range with time

I have a date range with time field that I want to use in a formula inside Fibery. I’m running into formatting issue’s. I succeeded in displaying the time like I want to, but it feels like a complicated workaround.

The date range with time field is named Timeslot and is set to March 28, 08:00 - 10:30

Problem: ToText(Hour(Timeslot.Start())) + ":" + ToText(Minute(Timeslot.Start())) displays as 8:0

I want to display the time as 08:00

My workaround:

If(Hour(Timeslot.Start()) < 10, "0", "") +
ToText(Hour(Timeslot.Start())) +
":" +
If(Minute(Timeslot.Start()) < 10, "0", "") +
ToText(Minute(Timeslot.Start()))

This displays as 08:00

Is there a better way of doing this?

If you want to have zero-padding for any number, a nice way of doing this is
Right("0“ + ToText(number), 2)

(this will force any integer up to 9 to be shown as a 2 digit number, and any number from 10 to 99 to be shown as is)

The same logic can be used for zero-padding larger numbers, e.g.
Right("000“ + ToText(number), 4)
etc.

3 Likes

FYI we have a feature in the backlog for allowing users to specify formatting (of dates/times) when using the ToText function. Fingers crossed this might get rolled out before too long.

2 Likes

That would be really nice! Thank you for the better workaround.