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

**URL:** <https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453>\
**Category:** Questions about Thunkable X\
**Tags:** solved, beginner\
**Created:** [December 20, 2021, 2:58am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453 "2021-12-20T02:58:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 20, 2021, 2:58am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/1 "2021-12-20T02:58:57Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/4/a47bd602c68382a8adda9296d621ca3f4f135be6.jpeg)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 20, 2021, 3:58am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/2 "2021-12-20T03:58:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 20, 2021, 4:34am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/3 "2021-12-20T04:34:35Z")

</div>

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](https://x.thunkable.com/copy/1d53662a1da3d58c8d6e54e0ee3ca80e)

(See the screen with your username on it.)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/d/fd8689d23ab176b6dab217126efb582aa73d683a.png)

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 20, 2021, 9:54pm UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/4 "2021-12-20T21:54:37Z")

</div>

This is awesome. Working so far. Thank you.

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 21, 2021, 12:02am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/5 "2021-12-21T00:02:47Z")

</div>

Here are the blocks I copied from your suggested solution:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/5/45777f1a3525676d2fcead4d71d5d7c3df985dae.jpeg)

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:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/9/e9437969a83ef87a77e70a98c55aada3f2e54ac5.jpeg)

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 21, 2021, 12:34am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/6 "2021-12-21T00:34:14Z")

</div>

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:

 ![Screen Shot 2021-12-20 at 4.44.48 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/d/fdddb4b2d4e618634307af63236e4befc289957e.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 21, 2021, 12:51am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/7 "2021-12-21T00:51:45Z")

</div>

> [@cohoes41a8gy](#):
>
> 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).

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.

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 21, 2021, 1:08am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/8 "2021-12-21T01:08:43Z")

</div>

Thank you. Found a workaround for this.

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 21, 2021, 1:11am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/9 "2021-12-21T01:11:36Z")

</div>

MARK SOLVED.

Thank you.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 21, 2021, 2:50am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/10 "2021-12-21T02:50:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 26, 2021, 10:27pm UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/12 "2021-12-26T22:27:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 26, 2021, 11:09pm UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/13 "2021-12-26T23:09:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 26, 2021, 11:25pm UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/14 "2021-12-26T23:25:24Z")

</div>

![Screen Shot 2021-12-26 at 6.21.41 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/6/864dc7955d604831a9f0009d14f555aa099eb3c8.png)  
 ![Screen Shot 2021-12-26 at 6.21.53 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/b/3b0347932b9baa53eb93354f89ec05c55405d3d9.png)  
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?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 27, 2021, 2:44am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/15 "2021-12-27T02:44:51Z")

</div>

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](https://docs.thunkable.com/time-input#functions) 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.

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 27, 2021, 3:21am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/16 "2021-12-27T03:21:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [December 27, 2021, 3:26am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/17 "2021-12-27T03:26:53Z")

</div>

Do you

> [@cohoes41a8gy](#):
>
> That’s too complicated

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.

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 27, 2021, 4:07am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/18 "2021-12-27T04:07:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [December 27, 2021, 4:16am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/19 "2021-12-27T04:16:53Z")

</div>

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! 😓

---

<div class="post-metadata">

**Author:** ![cohoes41a8gy](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cohoes41a8gy](https://community.thunkable.com/u/cohoes41a8gy)\
**Post date:** [December 27, 2021, 4:22am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/20 "2021-12-27T04:22:58Z")

</div>

No problem!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 27, 2021, 6:02am UTC](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453/21 "2021-12-27T06:02:25Z")

</div>

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.

[Next page](https://community.thunkable.com/t/solved-adding-time-from-a-db-to-user-input-time/1657453.md?page=2)
