Average of a time

Hi there,

is there any way that I can get the average of a time variable?

Example: If a user clocks on at 2:30, 2:29 and 2:31 then i need to calculate the avg of theses “clock on” times which should return 2:30.

Is this possible in any way?

I correct my statement. Flawless showed that it is indeed possible.

Yes, it’s possible @Archer. @pushingpandas Adalo certainly does support complex calculations. You just gotta know how to finesse the system :sunglasses:

Create a collection called “Times” and insert a number parameter called “ID#”, another number parameter called “Unix”, a date/time parameter, and a user relationship (one-to-many).

Add an input to your screen and name it “Timestamp Input” and set the default value to “Current Time MINUS Start of Today”

Add a 2nd input and call that “Hour Input”. Insert a custom formula with INT(Timestamp Input multiplied by 24). This will show you the hour.

Add a 3rd input and call that “Minute Input”. Insert a custom formula with INT((Timestamp Input multiplied by 1440 minus Hour Input multiplied by 60)). This will show you the minutes.

Add a countdown timer to your screen and set it to 3 seconds. Set the action to “Create” a new “Time” record.

Use the “Timestamp Input” to fill in the “Unix” number for the time, and current time for the date&time parameter.

Then, you can simply display averages by doing the same thing with 3 new inputs and calculations.

Average Unix = Logged in user > times > unix > average (Be sure to set the date format to “NONE”)

Average Hour = INT(Average Input * 24)

Average Minute = INT((Average Input * 1440 - Average Hour * 60))

So you can then use those 2 inputs as magic text in any other component.

And here’s what it looks like:

Okay. That’s quite complicated but when it’s work. good. I did not know.

1 Like

No worries my friend, that’s why I’m here :gem:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.