# Current Day vs Selected Day

**URL:** <https://community.thunkable.com/t/current-day-vs-selected-day/1581333>\
**Category:** Questions about Thunkable X\
**Created:** [October 26, 2021, 6:18am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333 "2021-10-26T06:18:55Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [October 31, 2021, 11:16am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/61 "2021-10-31T11:16:20Z")

</div>

@muneer alright, I have implemented all these procedures, however, when I run the app, Thunkable crashes. I think this may have to do with the iteration of functions. I will show each function in the process:

Variables:

 ![Screen Shot 2564-10-31 at 18.11.24](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/4/b4f4123824a413baf84cb8dc14bb10dfc1c63fff.png)

Getting dates:

 ![Screen Shot 2564-10-31 at 18.12.15](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/e/cee5f0357cba1d266130a5635f0f380e1fef757c.png)

Evaluating days in date:

 ![Screen Shot 2564-10-31 at 18.13.04](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/1/f106546ac95d43f02739fc3db0850016a3692634.png)

Comparing date:

 ![Screen Shot 2564-10-31 at 18.13.45](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f889c9a8594e0c5f4568314448effc7e7d86e792.png)

Calling functions:

![Screen Shot 2564-10-31 at 18.14.19](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/e/6ed2d526f5b1ff679586d8e8e92354fd1cce7e20.png)

Here is a [link](https://x.thunkable.com/copy/895adec8a287dc020dc6dd03ed6f6dca) to the project.

You will have to create a test assignment to see the procedure work.

Thanks!

---

<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:** [October 31, 2021, 1:04pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/62 "2021-10-31T13:04:35Z")

</div>

I’m out now and would not be able to see the project before this evening.

One quick way to locate the error is to add a label to the screen and in the screen `opens` event add a text to that label prior to each function and a wait block to see what stage you are.

This way you will focus your efforts in the problem block not all the blocks.

Anyway, I’ll see it later.

**[Edit]**

Just went through the app and added an assignment

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/5/a52eda1052f9471e9aa6b3d71f51b812a0ecb97d.png)  
No crash.  
Will need to test more and see what code give the issue you faced.

---

<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:** [October 31, 2021, 4:01pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/63 "2021-10-31T16:01:09Z")

</div>

If you’re interested in the days between 2 dates can’t you use that trick of calling an api that calls a Javascript to do that? or cinvery both dates to millisecond since 1970. Take the difference and convert to date? Or is the problem about parsing a manually entered date? Then it’s a challenge. Unless there’s already an api that does only that.  
: convert a human entered date to task date.

---

<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:** [October 31, 2021, 4:04pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/64 "2021-10-31T16:04:31Z")

</div>

> [@manyone](#):
>
> Then it’s a challenge

No, it’s not.  
I already designed a function to convert a `seconds since 1970` to human date. As you know the first round you are focused in logic to performance. So I have it working but need to enhance it further.

Check this if you like to look into it and give me your thought of enhancing it further  
[https://x.thunkable.com/projectPage/617d60166771f90011dd10ea](https://x.thunkable.com/projectPage/617d60166771f90011dd10ea)

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 1, 2021, 3:21pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/65 "2021-11-01T15:21:05Z")

</div>

Hi @muneer . I am thinking about how to best implement the for loop in these procedure. I think this may be the cause for the app instability. Currently, I have implemented the loop in the last procedure:

 ![Screen Shot 2564-11-01 at 21.47.22](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/e/ae5139ecec514d9dbd72850cfb1079f42daa7b4a.png)

Currently, the app will not crash when the screen is opened. However, if you navigate throughout the app and then return to the screen, Thunkable crashes. I have tried to implement this for loop throughout the procedures but nothing has resolved the issue.

Moreover, I tried your suggestion of printing values to a label in each function. This helped with fixing some of the logical errors in my code. Thanks for the tip.

Anyways, any suggestions on how I can improve app stability would be much appreciated. Here is the link:

[https://x.thunkable.com/copy/56e3ad8cad86b5ed4a6096ca5efcd6da](https://x.thunkable.com/copy/56e3ad8cad86b5ed4a6096ca5efcd6da)

Thanks!

---

<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, 4:44pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/66 "2021-11-01T16:44:10Z")

</div>

I just noticed in your code you do not process `current date` this causes all assignments to fall in the `Overdue` category.

You need to process `current date` by the function `days in date` to get correct comparisons.

---

<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 1, 2021, 5:15pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/67 "2021-11-01T17:15:27Z")

</div>

i think daysInGiverDate is mixing apples and oranges because it’s adding year and days together. for computing date differences between dates in the same year, it might work, but will fail when the years are different.

i think you should use the daysInUnixDate variable (unixdate / 86400) format as the base for subtracting dates. this is really the # of days since 1/1/1970.  
if you get two dates into this format, just subtract them and you get the difference in days.  
the challenge i was referring to was the conversion from standard date (year, month, day) to unixdate . the # of days since 1/1/1970 can be derived from there.

---

<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, 5:21pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/68 "2021-11-01T17:21:20Z")

</div>

I can do this easily. If you like the idea in the sample project then we can, maybe, work together and design the reverse to convert from year, month, day to Unix timestamp.

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 2, 2021, 3:18am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/69 "2021-11-02T03:18:46Z")

</div>

Thanks @muneer for noticing this. I think I may have sent you an outdated link as I actually did notice that issue and resolved it:

![Screen Shot 2564-11-02 at 10.13.52](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/a/4ac77fd62b5aea182da3c48ae67410c7c67b88cd.png)

The conditions are now working (I still need to refine them). However, there is still a major issue with app stability. It is prone to crashes quite a lot which I believe is down to the for loop. Any suggestions would be much appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 2, 2021, 4:32am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/71 "2021-11-02T04:32:00Z")

</div>

@muneer please ignore my previous replies, I have an update. The procedures are now working smoothly and the app stability has been improved. The crashes were due to the functions being called simultaneously at different point in the code. There is one final thing I would like to implement.

Currently, the code parses the dates and adds a label when the screen is opened **and** when an assignment is added. However, this is a problem as the for loop implemented within the function keeps adding the label every time when either of these events occurs. Therefore, would it be possibly to implement a condition that only adds the label to assignments without one? Additionally, the labels would need to be updated once the current date changes. Any suggestions on how to do this? Here is the link:

[https://x.thunkable.com/copy/3a2b3226d582ea825d22f88d7c834bd1](https://x.thunkable.com/copy/3a2b3226d582ea825d22f88d7c834bd1)

Thanks!

---

<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, 6:43am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/72 "2021-11-02T06:43:47Z")

</div>

You can do something similar to the function **All Filled**.

Create a function to receive the text entry as its parameter and check that none of the status wordings is available and return true or false according to the situation then you only process the ones that are not processed yet.

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 2, 2021, 12:17pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/73 "2021-11-02T12:17:37Z")

</div>

That sounds like a great idea @muneer . One thing, how would make it so that the list items are indeed processed when the current date changes? If the user’s task contains the label ‘Due today!’, how would the code update the label to ‘Overdue’ once the due date has passed?

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 2, 2021, 12:46pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/74 "2021-11-02T12:46:25Z")

</div>

**Update**

@muneer , I have had a go at making the function you suggested:

This function goes through each list item to check if it contains a due date status:

![Screen Shot 2564-11-02 at 19.42.19](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/5/253cd0b51244e80725b7f517e5ac849d6e24f5f2.png)

It is called in this function:

 ![Screen Shot 2564-11-02 at 19.43.37](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/3/43083efc12b5c2c13af80bc9e286c3b2f696b738.png)

The procedure is not working though. I think this may be due to the fact that the ‘compare dates’ function is a for loop and is calling the other ‘check due date status’ function which is also a for loop. I am not too sure. Any suggestions would be much appreciated.

Thanks!

---

<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:36pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/75 "2021-11-02T17:36:06Z")

</div>

You need only the **IF conditions** without the loop. You will check the condition before updating the status and if status is available then remove it along with the new line character prior to it.

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

This is the sample block.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/c/ac88acf4c84072b048682cc312d759a9b92c4a3b.png)

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 3, 2021, 1:28am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/76 "2021-11-03T01:28:55Z")

</div>

@muneer I have tried to make this a function with the parameter `assignment` so that I can call this throughout the code:

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

However, when I call this in a different function passing `j` as `assignment`, the function is not completed:

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

This procedure worked fine when I did not add a parameter to the function but I want to add a parameter so I can pass in different variables. Any idea on what could be causing this?

Thanks!

---

<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 3, 2021, 5:19am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/77 "2021-11-03T05:19:00Z")

</div>

i found an article (written by Victor Vogelpoel in 2002!) that shows how to convert year-month-day to excel serial date and back. it’s pretty cool! it only takes a little adjustment to make it work for unix dates. i translated it to thunkable and it works!

here’s the project (warning: the formulas are ugly!)  
[https://x.thunkable.com/copy/31e9f95fec50f854e131dad9f2f05f57](https://x.thunkable.com/copy/31e9f95fec50f854e131dad9f2f05f57)

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

right now it recognizes unix dates in milliseconds, but you can convert them to days by dividing by 86400. the calendar date needs to be entered as in 2021-12-31 (hyphens between the parts).

this is the time we need a function in thunkable IDE to be able to “textify” (convert to text) blocks AND a reverse function to “blockify” the text back to blocks. this would eliminate the re-typing we have to do when we want to bring a subroutine into our program. just wishful thinking. or better yet, if we only had a way of building thunkable libraries!

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 3, 2021, 7:16am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/78 "2021-11-03T07:16:54Z")

</div>

> [@manyone](#):
>
> if we only had a way of building thunkable libraries!

Yes, that would be very useful! A great suggestion for @domhnallohanlon .

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 3, 2021, 11:43am UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/79 "2021-11-03T11:43:24Z")

</div>

@muneer , how would I make this as a function that I could pass variables in:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/c/ac88acf4c84072b048682cc312d759a9b92c4a3b.png)

I have currently made this however, it does not accept ‘j’ as a variables:

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

---

<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 3, 2021, 12:39pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/80 "2021-11-03T12:39:53Z")

</div>

This is how I would do it.

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

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [November 3, 2021, 2:52pm UTC](https://community.thunkable.com/t/current-day-vs-selected-day/1581333/81 "2021-11-03T14:52:05Z")

</div>

@muneer , is there a way of passing a parameter like I tried to do above? This is because when the user deletes an assignment, the assignment is archived. I would therefore like the due date status to be removed from archived assignments. I could use this function and pass in ‘item’ as ‘assignment’ when a list item is clicked.

The only issue is that it is not being completed as outlined above. When I pass in ‘j’ (the list item), it is not being processed by the function. Any idea why this could be occurring?

Thanks!

[Previous page](https://community.thunkable.com/t/current-day-vs-selected-day/1581333.md?page=3)

[Next page](https://community.thunkable.com/t/current-day-vs-selected-day/1581333.md?page=5)
