Show information exclusively on a specific day of the week

Hello.

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.

Do you have any recommendations?
Thanks.

Hi @ionutilie,

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 :slight_smile:

Best regards, Victor.

1 Like

Hi @Victor
Thank you for your answer.

If this is the post you are referring to How to derive weekdays from a date I did not manage to apply it in my case. And also, I guess that will translate the name of the day.

Yes, I thought of a relationship between numbers and days, exactly as you mentioned, but it is not yet clear for me how to implement it.

Thank you!

Hi @ionutilie,

Yes, I mean that post (if you don’t mind please correct your link :slight_smile: ).

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.

Best,
Victor.

3 Likes

Hello @Victor .
I still have no clear solution.

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.

Thank you.

Hi @ionutilie,

Here is the logic:

  1. You add a Number property to Users collection, call it, CurrentDayID.
  2. 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
  1. 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).
  2. 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.

Best,
Victor.

3 Likes

Thank you @Victor ! :partying_face:

1 Like

You’re welcome! Don’t hesitate to share the result :slight_smile:

1 Like

Thank you again @Victor! Brilliant solution @karimoo !

Screenshot 11-17-2021 16.32.23

1 Like

Great that it worked!
I wonder why dayID is 4 - it’s Wednesday :thinking:

3 Likes

Haha! Greeeat question!
I am making some tests but it is the right solution.

Now it behaves like Sunday = 1.

  • the formula is identical even if I copied it without understanding it.
  • I also changed the format to the Date Picker (Date & Time, Picker, Text).
    No change.

If it works after the tests, I’ll keep it that way with this anomaly. :partying_face:

2 Likes

Hello again @Victor !

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!

Hi @ionutilie,

Welcome to the wonderful world of Adalo’s date&time management :rofl:

Could you please provide a screenshot of how do you calculate the DayID? Also, what is your timezone (I assume you’re somewhere in America? or not?)

Best regards, Victor.

2 Likes

:slightly_smiling_face:

Thank you @Victor !
This is the screenshot.
Screenshot
And my current timezone is GMT+2 (Bucharest).

Thank you!

Hi @ionutilie,

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.

Please let me know about the result.

Best,
Victor.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.