Hey everyone, brand new to Adalo and loving what I am seeing so far.
I have come across a stumbling block early on and that is I am trying to use duration in my custom formula’s to do calculations but there doesn’t seem to be a way to do it. I came across this thread:
But that thread has been closed and pointed to feature requests, so I am taking it isn’t possible?
Can you elaborate? Are you using duration to setup triggers or just to calculate? If you are wanting to calculate using a duration you can use a time stamp that is triggered by a button press and you can use current time to calcualte the difference.
Hey @Drearystate, I need the user to input a duration for example 04:30:00 and from that, I need to do certain calculations, for example, divide it by a fixed number to get a time in minutes. And then take that time and multiply it by a certain number.
Adalo calculates dates using UNIX timestamps which traditionally are the number of seconds since UNIX was implemented back in 1970. The only difference is that Adalo handles these in days, meaning that if a typical UNIX timestamp is 1634310307 (number of seconds), the day equivalent in Adalo is basically just a moved decimal point: 16343.10307.
Knowing this you can create records in a collection called “Duration” that have the duration in this format and then add the selected duration from a dropdown to a selected date in a date picker. Here’s a very basic cloneable app that demonstrates how this could work. Note that the durations are stored as decimals.
Ok, I’ve figured out how to get the duration into the decimal without using the date and time picker. (The reason I didn’t use the date picker is because it includes the day and am/pm)
Is there any way to display just the time from that decimal?
Yes, but only on the front end and it must be pulled from the entire timestamp, not just the durations decimal value. You can format the datetime as just a time, by clicking on the pencil icon of the magic text.
Another thing you can do is create multiple dropdown durations with hours, minutes, and seconds separated out then add them together and to the initial date to get the final new datetime.
Ok cool. is there a way to display the output as just the time in hh:mm:ss without the PM, as opposed to the date & time? So in the example below, 11:08:00 instead of 10/15/2021 11:08 PM?
I just updated, but the short answer is yes, although not really in a format with mandatory 2 places in each digit. Just save it to the User’s record as a string or just display the values of the inputs themselves as I’ve done in the demo.