Calculate the time difference between two time stamps?

Continuing the discussion from Time Clock or total hours between timestamps?:

I have a button that starts an action and a button that ends an action. I need to calculate the duration between the two clicks. Is this possible in Adalo?

I’m adding “current time” using date/time stored in a Number when a ‘game’ starts


and the same setup to end a game.

Time get’s stored like this:

However, not sure how to get the diff in time between the two. Tried using INT() and ROUND() on both times and using created date and updated date. all which result in a NULL calculation.

3 Likes

Hi @uripides ,

After you subtract and get only the fraction (if it is less than a day), multiply this with 1440 (24x60) to get minutes, multiply 86,400 to get seconds.

Use INT if you want to just get the time from single date.

But in your case here, 2 dates, no need INT to get fraction.

1 Like

@Yongki Thank you for the response. That did the trick! The next obstacle is to calculate player time. Im tracking this with the stopwatch feature which Im using Text format for.


Should I capture that using Number format?

For those interested in getting minutes from Stopwatch as a Number you have to take the milliseconds and divide by 60000. That will give you minutes. Then use ROUND to make it a whole number.

Ex: Total time from stopwatch_time: 763289
therefore: 763289 / 60000 = 12.72148333 use ROUND and you get 12.

Going one more step to find avg time, add all the total times from stopwatch (all_times_from_stopwatch/60000) then divide by the number of recorded times stopwatch was recorded by user or instance (using “Count”) and you’ll get the average!!!

Fun times!! I hope this helps someone. It was a beast to figure out.

3 Likes

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