[Solved] How to use date functions in Thunkable X

Continuing the discussion from Dates Functions:

Hi

1- How can I add # of days to a specific date, for example adding 100 days to 28/02/2019.
2- How can I calculate # of days between 2 dates, for example how many days between 15/04/2018 and 20/03/2019.
3- How can I get the day of the week from Jason for specific date, for example what is the day of the week on 15/05/2018
4- Is it possible to have Date Picker to choose dates from in Thunkable X same as the one in thunkable classic.

thanks

2 Likes

I need the answers of these questions.

Hi @ali4oman and @bymaho,
Answer 1:
If you have a table of how many days are in each month, you can add a number of days to your date by:

  1. if (days left in month) < number, set new date to last day of original month, set number to (number - (days left in month)).
    Example: 14 Feb 2019 + 100 days = 28 Feb 2019 + 86 days
  2. For as long as the next month of days is less than number, add 1 month to new date and take that many days away from number
    Example: 28 Feb 2019 + 86 days = 31 Mar 2019 + 55 days = 30 Apr 2019 + 25 days
  3. Add the remaining number to your date
    Example: 30 Apr 2019 + 25 days = 25 May 2019

Answer 2:
Using a method like above, if two dates are in different months the # of days between them is (days between start date and end of month) + (days between end date and start of month) + (number of days in any full months between start date and end date)

Answer 3:
If you use the date input in your app, you can see what the day of the month was on a given date. If you want to type a date and get a day of the week, use an API with our Web API component for this purpose.

Answer 4: There sure is!

Hope this helps :smile:

4 Likes

a little bit crayz but it works. Anyone can try it.
These blocks calculate the exact date between two dates.

3 Likes

Hey! This is sweet! Thank you!!

I will be using this to figout out EPOCH time to use timestampps for data filtering from airtable!

3 Likes

Hi @jane.
How to use blocks for your answer?
Could you show me?

I will use 2 date pickers and make a list of date.
For example, 2020-02-11,2020-02-12,2020-02-13,2020-02-14

I can’t make different days each month.

please give me an idea.

Thanks

@go1tentcjzwu - can you share a screenshot of the blocks you are using at the moment and we can point you in the right direction from there.

Thanks.

I use 2 date pickers.
Left blocks is first pick.
Right is second.

Thanks @go1tentcjzwu

So what are you trying to do here?

Are you setting start dates and end dates? do you want to create an array of dates between these two values?

My solution is up there.
I solved it.
Thanks

2 Likes

Hi I tried using the method you did but how to fetch the values from API?