I need to display some information only on certain days (e.g. if it is Monday, than Monday information, if Tuesday, than Tuesday information etc.).
For this I created an input field with Current Time (Day of week), which takes the date as the name of the day and if the current day real name is identical to the day to be displayed, then everything is ok. This is also here: Show a video based on the day of the week
So, this method is functional, but it has a limit.
The input field from Adalo, adds in the input field with Current Time (Day of week) the current translated, depending on the language of the device / browser used.
So if the user’s device or browser has a default language other than English, then the information in the input field is not recognized and therefore user info is not displayed.
You can search for the post by @karimoo where he explained how to calculate the number of the day of week. I don’t have it at hand right now, the name looked like “calculating days of week by numbers” or something similar.
Just in case, in my experience that way of calculation always returned 0 - 6 (0 is Sunday, 6 is Saturday), though in the example it is 1-7. But I never had time to explore why is that
Yes, I mean that post (if you don’t mind please correct your link ).
This approach works for me pretty well to decide which day is it now. And after that I can filter offers based on this day ID.
I use current time in a text label (formatted to be displayed as day) to show the day’s name, no need for additional collection.
I am able to know what day is using Current Time (Day of week) from an input field.
And if the device / browser show the Current Time (Day of week) in German language and my condition is if contains Sunday in English language, there will be no match, no list displayed.
You add a Number property to Users collection, call it, CurrentDayID.
Upon entering Home screen, you calculate CurrentDayID using @karimoo’s method. You will get a number in the range from 0 to 6.
0 means Sunday
1 means Monday
You change the visibility of your Group 15: it will be visible if Logged-in User → CurrentDayID is equal to 0 (as you’d like to show this group on Sundays).
You do the same for the other “day-based” groups.
Hope it’ll help. The only potential problem I am aware of is that sometimes (I don’t quite understand when) day ID for Sunday will be 7. But this is app-wide, you just need to test your app on Sunday and see which DayID is returned.
I thought the topic is closed, but I tested / verified and the result is a little strange.
In fact, every day, at my local time 15:00 the app and the calculation change the current day to the next day.
So, for example, until 15:00 I am on Monday, from 15:00 I am on Moday + 1 = Tuesday according to this calculation …
At my local time 15:00 in Sydney is 00:00, which is the place where you actually move to the next day. I don’t know if this info matters.
Do you have any suggestions in this context? Thank you!
I believe the reason for the problem is that you are taking the value from the DatePicker directly. Is it “date” or a “datetime” type of picker?
As a workaround, I’d advice add a “TempDate” property to Users collection, make it a “Date” type. With the first action, update this property by setting the value taken from the DatePicker (this should result in storing the start-of-that-day in GMT+0) format.
And after use that property as a source for dayID calculation.