# Finding number of days between two dates

**URL:** <https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318>\
**Category:** Questions about Thunkable X\
**Tags:** beginner, date\_picker\
**Created:** [March 6, 2021, 7:04am UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318 "2021-03-06T07:04:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![p.powercoders1i0t](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@p.powercoders1i0t](https://community.thunkable.com/u/p.powercoders1i0t)\
**Post date:** [March 6, 2021, 7:04am UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/1 "2021-03-06T07:04:37Z")

</div>

I’m trying to find the number between two dates. I tried to remake this JS code in Thunkable:

```
const startDate = '2020-01-01';
const endDate = '2020-03-15';

const diffInMs = new Date(endDate) - new Date(startDate)
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);

console.log(diffInDays)

```

I tried to get the milliseconds between the two dates by subtracting them and then dividing them 8640000 to turn them back to # of days. but got stuck when i try to get the new Date value.

**Here are the blocks so far:**

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

I’ve been unsuccessful, has anyone found a way to easily do this?

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 6, 2021, 7:27am UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/2 "2021-03-06T07:27:21Z")

</div>

Yeah, even I have this same question. Also, how do you find the date a certain number of days after a specified date?  
For example, I want to find 14 days after 26 February. How do I do that?  
Also, I want to check if a given date is 14 days after another certain date. For example, I want to check if 19 July(let’s say that the user inputted that date) is 14 days after 29 June, and display a message based on whether it is or isn’t.  
Any ideas on how to do this?  
Thanks

---

<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:** [March 6, 2021, 2:37pm UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/3 "2021-03-06T14:37:28Z")

</div>

🦹🏻‍♂️

You guys need to use a webviewer and JavaScript. That’s it!

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 6, 2021, 4:35pm UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/4 "2021-03-06T16:35:24Z")

</div>

Thanks. How do you post dates the user has inputted? I know a little JS but this is quite above my level.

---

<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:** [March 6, 2021, 4:50pm UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/5 "2021-03-06T16:50:49Z")

</div>

I would send all data as a JSONobject in the webviewer and work with it as such

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 6, 2021, 4:54pm UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/6 "2021-03-06T16:54:05Z")

</div>

Do I do this using the same code that @p.powercoders1i0t has given in his code?

---

<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:29pm UTC](https://community.thunkable.com/t/finding-number-of-days-between-two-dates/1147318/7 "2024-11-08T13:29:01Z")

</div>


