2

Hi all I want to convert a number of minutes to HH:mm format and display that as a text in a listview. As an example: 90 Minutes → 1:30 I tried some funcitons in the expression editor but they keep throwing errors. Anyone know how to do this? Seems easy but I can’t get behind it. Thanks!

asked

Lenny Puente

2 answers

5

I think using modulo can help here.

Calculate the Minutes not part of a complete hour:

`$Example/ExampleInteger mod 60`

Calculate the number of Hours:

`($Example/ExampleInteger - $Minutes) div 60`

Create a string using the Hours and Minutes values, adding leading zeroes if necessary:

```
(if $Hours < 10 then '0' else '') + toString($Hours) + ':'
+
(if $Minutes < 10 then '0' else '') + toString($Minutes)
```

answered

Marius van der Knaap

3

There are likelty java actions out there that do this, however if you want to do it in a microflow. One solution could be to use a microflow to count the number of time 60 can go into the number of seconds, add 1 to a variable called minutes for every 60 seconds, then add on the remainder in a create string variable.

seconds = 200

if $seconds >= 60

then $minutes + 1 and $seconds –60

else end loop

Repeat this

Until $seconds no longer is less than 60 60, then create a string variable

$minutes+’:’+$seconds

This should output ‘3:20’

answered

Garion Swann