How to calculate the time interval

Hello everyone. Tell me how to calculate the interval between two records with time. I have a database in which I record the time when the user pressed start and the time when the user pressed stop. I need to calculate how much time has passed between these two actions. Thanks


End time minus start time…

Hi there, @bluesun440… it would be much easier (and essentially the right way to do it) if you were using date fields instead of text fields to store the start and finish times. At that point (and as Adam said), you could subtract the start time from the finish time and format it as hours, and you would have what you need.


1 Like

but I use text fields because no other dates are recorded. The expression is burning red

I don’t know what that means, but I’m guessing it means the user does not need to input a date because the date will always be the current date. If that is the case, I would still use a date field and a date/time picker, and I would probably set the initial content of the date/time picker to the current date/time. If you use date fields, you will have operators that let you perform calculations on the dates/times. If you use text fields, you don’t have those operators.

Exactly. However, even in the input field, the expression is highlighted in red if it is formatted to display the current time.

and when trying to write to the database, it gives an error

First, I would use an actual date/time picker and not an input element with a content format of date. Second, the expression is red because you are formatting the current date/time, and that turns it into text, so you are trying to put text into an input that wants a date/time.

yes, it really works, thank you. But how can I get rid of the date field in the standard element? I need the record to be only in time format with seconds, without the current date

This thread describes another way to go, and it might help.

If it was me, I would probably do something hacky and somehow hide the date part of the picker or I would set it up so the user couldn’t change the date from the current date.

Thank you. Will try)

This topic was automatically closed after 70 days. New replies are no longer allowed.