Sorry maybe click on it and it will expand?
I believe something wrong with the forum server/app. Let’s wait for a while and check later.
You are subtracting the app variable current date
from itself. This will yield ZERO all the time.
Thank you, @muneer , I have fixed this. I have created conditions that change the label for the assignment depending on its due date:
However, the logic statement app variable current date = app variable assignment date
is not returning true. I have checked to see if the the two variables are the same if I set the assignment due date as the same current date and they are indeed the same. Therefore, why won’t this logic statement returning true?
Can you check the length of both variables?
If could be a white space
in the start or the end of the variable that preventing it from evaluating to true.
Also noticed that your last condition in impossible. The value cannot be <= and at the same time > the same value.
Thanks for correcting the last condition. I have tested the lengths of each variable and they are indeed the same. Whats more is that I set a label’s text to current date - assignment date
and the label displayed 0.
Good.
So if you change the condition from equality to testing for ZERO then it should solve your issue.
This condition still doesn’t work. I have added a link if you would like to take a look:
https://x.thunkable.com/copy/685a2b4670ffa54befe4a72fff789836
The snippet causes the two dates not to be equal.
Thank you @muneer for noticing this. I have now noticed that, once the current date was corrected, the assignment date and current date are not the same. I have printed each date for October 30 2021:
assignment due date = 202101030
current date = 20211030
It seems that an extra ‘0’ has been added in the parsing algorithm. Any way to fix this?
Thanks!
This is the source of the extra “0”
I have previously asked you to get the length of both variables. You should have noticed this problem at that stage.
This is the code you kindly supplied earlier:
Should I change it to:
in list app variable month list:
find first occurence of current month
Thanks @muneer . I am very sorry that this is getting increasingly complex, but I have found another major issue. The current conditions set up work if the current month and the assignment month are the same. Otherwise, the logic doesn’t work. Here is the current conditions:
Here, if the say the assignment month is October and the current month is October, all the logic will work. However, I tested if I set the assignment month to November and the logic fails. For instance, app variable assignment date - app variable current date = 71
whereas if both have the month October it = 0. I am completely stumped as to get around this!
Can you give more info?
What values you used for Assignment Date
and for Current Date
?
Can you print them to a label and then subtract them by using the calculator? This is just to confirm if the number given is correct.
For Example:
If Current Date
is today (20211030) and Assignment Date
is the 1st of November then the difference is 71 as numbers not as dates.
@muneer For assignment date I have used 1 November = 20211101 and current date is today. Yes, these dates are only 2 days away however, when their numerical forms are subtracting from one another, it equals 71. Therefore, the conditions in which check the numerical forms (parsed from the string date) of each date will not work. Does this clarify? Thanks.
Let’s think out of the box.
Linking a Google spread sheet and pass the dates to it will quickly give you the difference between the dates without all these blocks.
Another way, is to take the year and add to it the number of days from the start of the year to date.
This means you need to create a list with number of days in each month or number of days accumulated until the previous month and add the number of days to it.
Example
year is 2021
Add to it the number of days till September because we are in October
- 31
- 28 or 29
- 31
- 30
- 31
- 30
- 31
- 31
- 30
Then add the number of days in the current month which for today is 30
You get a total of 2324
The assignment date being the first of November will be 2326
This will assure you correct number of days based in calendar days.
One issue remains which is a function to determine if the year is a leap year to add 1 to the total.
@muneer these are great suggestions.
I have not had a lot of experience using google sheets with Thunkable so how would that work exactly?
You have used Local Tables
in your app. So I assume you know how to add a table but instead of choosing make your own table you will choose Google sheet
From the Data Source
, you will click on the + and click on Create New
button.
Select Google sheet
. This will take you to this screen
click on Select a Sheet
You will get a list of Google sheets available in your Google drive. Select the required sheet and that’s it. You would have created the connection to your Google sheet in your app and now you can write to the sheet and read from it.
@muneer I understand linking google sheets but how would you compare the dates using it?