[Solved] Adding time from a DB to user input time

App will calculate how much time a user can be awake before entering required rest based on two variables. Per the table below, If a person wakes up between 0000 and 0359, they can only work for 9 hours in column 1. Wake between 0600 and 0659, they can work 12 hours in column 3, etc. I need help to have the user input what column they are in (they know), then what row they are in. The app would return the appropriate number from the green shaded area. Has anyone seen a similar project I can copy to achieve this? I know how to create buttons the user can select for the rows and columns, I don’t know how to have the app pick the appropriate green value based on the user’s input.

I would use two kist viewers to allow the user to select each value. Then, find the row based on the list of values block for the first column of your data source. Get the list of values for that row, And finally, reference the matching item number from that list and return the value there.

1 Like

Here’s a demo with a smaller dataset. You’d need to include all possible values in the red text block. It’s a little convoluted how it works but it does seem to work.

https://x.thunkable.com/copy/1d53662a1da3d58c8d6e54e0ee3ca80e

(See the screen with your username on it.)

2 Likes

This is awesome. Working so far. Thank you.

1 Like

Here are the blocks I copied from your suggested solution:

The names of the rows, columns and variables have changed. I added a block to change the list text to a different color when selected (but it changes the entire list, not the selected item which I need to fix). Here is the database:

Your screen returns the correct value. Mine reruns “null.” I can’t find what I’m doing wrong.

You’re getting the index number when you click which is the item # in the list of values (1, 2, 3, etc.). But you’ve named your columns “1 leg” instead of “1” as in your first screenshot and in my demo. So when you try to get the property of the row, you’re getting “1” or “2” instead of “1 leg” or “2 leg”.

To fix that, I believe you need to replace this index block with the green item block:

The List Viewer’s properties are for the entire list. If you want to change a single item’s color, you would need to use a Data Viewer List (DVL) instead. There are quite a few differences between working with List Viewers and working with DVLs. Also, this is possible with DVLs in the older Snap to Place interface but not in the newer Drag and Drop interface.

Thank you. Found a workaround for this.

1 Like

MARK SOLVED.

Thank you.

1 Like

Glad to hear it. You can mark a post as the solution.

Now that I have a table that generates a time increment, I need to add that time increment to the time entered by a user in a label on a different screen in the app. Is that possible?

Sure. You can store values in variables and access them from any screen. Also, in addition to assigning a value to Label 8’s Text in the above screenshot, you can assign that same get property block to a variable to store it for later use.



Here is what I tried. Changed some of the names. Assigned a new variable “MaxFDPvariable” with the same “get property” block. On the next screen, I tried to add the variable to the “Time_Input1” block, but I’m sure you can’t add text to a time field. It might work if the variable was formatted as time?

Yeah, I think you’re having a problem with data types not matching, especially when trying to add them together.

I haven’t used Time Inputs before so I’m not sure how helpful I can be.

What are sample values for call Time_Input1's Get Time and app variable MaxFDPvariable? That is, if you assign each to a label, what is displayed?

Edit: okay, you can use the time functions from the documentation to get specific values from the Time Input component. Do that and then figure out how to combine that with the time value you already have as a variable.

Time_input1 would yield something like 23:15. MaxFDPvariable could be “10.5”. Easiest would be to have a label for hours, a label for minutes, and then add them separately. Or convert everything to minutes, add, then divide by sixty, then convert the fraction to minutes. That’s too complicated. I can change my MaxFDPvariable to “10:30”, but still don’t know how to add that to 23:15 and it is still one field which can’t be separated. I just can’t get apples to apples.

Do you

Sometimes this is the way

What are you hoping to achieve here?

Add a duration of time to a duration

Or

Add a duration of time to a date/time and get a new date/time

Or

Add time to a time and get a new time irrespective of the day that time slot occurred in.

The point of this whole thing is that law dictates how long an employee is allowed to work. The length of time allowable depends on when work starts and how many shifts are performed. I have a table with shift numbers and allowable work times based on those shifts. The other input is the time the employee comes to work. The user enters that time, the app goes into the table, finds the regulatory time, and adds it to the user’s start work time. I don’t care about date, I just want to add time to a time irrespective of the day that time slot occurred.

Sorry! I had only read as far as the post after the solve. I realize now my solutions wont work for your use case anyway! :sweat:

No problem!

There are several ways to parse text strings. I can make you a demo later but the text substring and make list from text blocks come to mind as useful here.