Convert number into Time

I want to convert a given number into time.
E.g. the user writes 200 to an input field and this number is stored to database

Then all the entrys of database should be add up and converted in one formula.
so from different entrys (50, 70, 100, 3, …) should result one result (–> 223) and this should be converted in this scheme: 2h 43min (in one formula) (so every 60min has to be converted to 1h)
→ the result then is shown at an title component

How should be the formula to access this?
Thanks a lot

1 Like

I now tried to use this add up all my data entries:

I have 14 Data entries with date and “menge”. “Menge” is each entry you see below."

450, 210, 20, 20, 60, 75, 270, 315, 15, 25, 130, 70, 340, 120

But it doesn’t add up all of them. It only gives 0 as the result. The shown result should be 2120.

1 Like

0,7166666667 *60 = 43
3 hours and 43 minutes.
If you use an sql database, you might be able to do this with the SUM() sql function in your database. And then do the calculations in appgyver. I haven’t tested this.

1 Like

I’m only using client-side-storage. I tried to use the SUM() function, but it does not work.
Number type is not assignable to list type

1 Like

you need to check where you are trying to assign this function,
Because as it says one of your variables is number but the result of your function should be a list.

You could make an extra page variable called “sum”. Every time a new entry is submitted, make a logic that will add the entry to the “sum” variable, starting from zero.
so every time an entry is added it goes:
“sum” = “sum” + “entry”

“sum” = 0 + 20
“sum” = 20 + 15
“sum” = 35 + 70
“sum” = 105 + 12
and so on

You can do your conversion with the “sum” variable.

example conversion:
if “sum” is 250 in minutes
Hours → “sum”/60min => 250/60=4,16666667 (use function FLOOR to get only the 4 which is 4 hours.)
Minutes → 0,16666667 * 60min = 10,0000002 (again use function FLOOR to get only the 10 which is 10 minutes)
Seconds → 0,0000002 * 60sec = 0,000012 (again use FLOOR, in this case it happens to be 0 seconds)


thank’s for this explanation. But i think it’s not possible to put your example conversion in one formula because there are multiple steps to do and a formula only do it one step. Next problem is, that i have this multiple data entries and i also need to be able to delete them (and if they are deleted, their count have to be substracted from the result). Also a formula can’t figure out that it only has to use the decimal part i think.

I tried to use SUM_BY_KEY. It does not show any failures, but as result it only shows 0. I don’t know why, because my data entries are numbers. So normally i think this should work. (But it doesn’t)

1 Like

Now i’ve found the problem. It has problems with my input variable. Normally i wanted to get the input from an input field and then saved as record. But this (don’t know why) does not work. Even if i have the page variable that is set at the input field, created as number type. I also tried to change the input field only to number type, but it does not work.

So i now tried to use Prompt Number in Logic and now it works perfect.

1 Like