# Duration between times

**URL:** <https://community.thunkable.com/t/duration-between-times/1592086>\
**Category:** Questions about Thunkable X\
**Created:** [November 1, 2021, 1:33pm UTC](https://community.thunkable.com/t/duration-between-times/1592086 "2021-11-01T13:33:33Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 1, 2021, 1:33pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/1 "2021-11-01T13:33:33Z")

</div>

i found a solution in a post  
[[Calculate Time Duration - #8 by muneer](https://community.thunkable.com/t/calculate-time-duration/1361156/8)]

but there is a problem the worksheet must not have more columns than the data source otherwise it does not work and therefore the duration can only be calculated after if I am not mistaken  
Is there a way to calculate the duration as you enter start time and end time or you have to calculate the duration in the application but it seems rather complicated

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 1, 2021, 1:36pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/2 "2021-11-01T13:36:04Z")

</div>

Can you explain more what you exactly want to do?

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 1, 2021, 4:56pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/3 "2021-11-01T16:56:02Z")

</div>

each employee can report their in and out times in a spreadsheet through the app  
What I want ? it is to calculate the time spent in the walls using the spreadsheet

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 2, 2021, 3:49pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/4 "2021-11-02T15:49:56Z")

</div>

If the start and end times are both the same day then you can change both times to the number of minutes and take the difference then divide by 60 to get back the hours and the remaining is the minutes.

Very easy function.

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 2, 2021, 5:41pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/5 "2021-11-02T17:41:42Z")

</div>

Hi

what I see as a difficulty is when the dates are not the same day it is the general form that I am looking for which can be used in all cases if you have a lead …

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 2, 2021, 5:54pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/6 "2021-11-02T17:54:22Z")

</div>

Then you can use the solution I gave previously for the Google sheet.

Every time you want to get the time difference between two dates, just update the sheet in row one and read the result. Do this for every line in your form or screen.

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [November 2, 2021, 6:42pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/7 "2021-11-02T18:42:29Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/7/175e2f84f10fb6a6f689d0ea198ae43e8b652a25.png)

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [November 2, 2021, 6:53pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/8 "2021-11-02T18:53:31Z")

</div>

if you want duration minutes always, just multiply dur by 24 \* 60, ie. in example above. =H2_24_60

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 2, 2021, 7:00pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/9 "2021-11-02T19:00:08Z")

</div>

Can be this simple  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/2/52afbd1d2f8ff3519d7e30d8e958242135939102.png)

The difference column is just `=K2 - J2`  
And format the cell as “Duration”

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 4, 2021, 6:21pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/10 "2021-11-04T18:21:38Z")

</div>

hi

I appreciate the help you give me and I agree with you calculating the duration in a worksheet it’s simple except that my data is entered in the worksheet on five columns with the create row block

 ![Capture d’écran 2021-11-04 à 19.24.00](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/1/21e66a586c435bf244ca658434516fad37036406.png)

when I define duration in the worksheet with the formula corresponding to duration (in the sixth column) it does not work and I tried several times

I need this data for the operation of my application I do not see the users entering the spreadsheet to calculate this data

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 4, 2021, 7:57pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/11 "2021-11-04T19:57:28Z")

</div>

What I would do is:  
I will create a Google sheet with 2 sheets in it.  
One sheet is my data rows  
The other sheet has the date calculation function  
Every time I create a row, I will enter the start and end time in the 2nd sheet to get the time between them and then create the row with all the information in the 1st sheet.

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 4, 2021, 8:25pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/12 "2021-11-04T20:25:05Z")

</div>

all this without using Apps Script ?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 4, 2021, 8:59pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/13 "2021-11-04T20:59:36Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/2/124979f9244c6e7fdea702753fed184bb0e6d76d.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/2/1271be04aa31293f408c5d8aafd1cdf5c37f3208.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/b/5be44e1934d0bfd8a7bb6dc505398ae38010bf23.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/f/7fcba1c0435a82b8f6b887047aa96df84a383331.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/1/a1da6aac1961c343760163239774ba33f8d1893e.png)

To view the saved data, I used the click of the `Data Viewer List`

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/2/22ace9f652e28eb81fd9e77fbf5f375f1bb21da7.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/0/b02b90e8887a3f2ce52712fe341c3122544454ff.png)

This is all Thunkable and the 2 sheets. No outside scripts.

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 6, 2021, 4:33pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/17 "2021-11-06T16:33:31Z")

</div>

hi

This is a well documented solution but in my application I sometimes get this error code

> The parameter Parameter 1 of the MINUS function expects values ​​of the number type. But 6-11-2021 17: 4 is of type text and cannot be forced to be number.

I read the dates / times with the following blocks

 ![Capture d’écran 2021-11-06 à 17.25.19](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/0/0050b2267e1da552081ae2d86a26d951dfddbacf.png)

But should you use text boxes or numeric variables for the calculations?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 6, 2021, 4:37pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/18 "2021-11-06T16:37:08Z")

</div>

What format are you applying to your columns in Google sheet?

If you apply dd-mm-yyyy then you have to pass to the sheet 06-11-2021

The columns in your google sheet has to be formatted as **dates** , this will allow Google to convert internally the text you pass to it to a number.

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 7, 2021, 5:22pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/20 "2021-11-07T17:22:30Z")

</div>

hi

I think I followed your explanations but from time to time without changing anything in the blocks (it seems to me) the dates become texts and introduce errors

a big thank you for this initiation to objects

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:14pm UTC](https://community.thunkable.com/t/duration-between-times/1592086/21 "2024-11-08T13:14:29Z")

</div>


