Activate the purchasing services according to the opening hours: morning and afternoon

@stffnc1974 @jeremy I just created a post on how to work with time calculations.
First, read

If you want to compare time slots such as opening shift, you basically need to compare the decimals/fraction part of the Date&Time field.

I tried the following:
I created a Collection with two additional Number fields to store the time information for start and end:
image

Using a Form, I first create an entry for the shift data.

Note that there is a second action to update the calculated time fractions:


The formula basically uses the INT() function to cut off the days before the decimal point.
The entries in the database look like this:

To make the Order button only Sometimes visible I need to calculate the time fraction of the Current Time and make it available on the screen:
image

I used the following to test it:
First I created another Collection to store the calculated time fraction:
image
Holding just one record:
image
For multiple users, you need to link this to the User collection (I skipped this here).

Next, I added a Button to the screen AND moved the button into a list (Make List):
image

This list can now hold the NOW collection:
image

The Button has two actions:


The first one is calculating the time fraction of the current time and updating it to the collection.
The second action is linking to the target screen:

Now I have the data available to fill the fields to make the order button only visible when the current time is between the start and end of the shift:
image

In addition, I also calculate, how much time is left until closing:
image

The text label uses a Custom Formula:
image
which looks like this:
image

To get back to the minutes I have to multiply the difference with 1440 (minutes per day) and use the ROUND() function.

2 Likes