Only show events occurring during user's available times

My brain is melting trying to think how to do this so maybe someone can give some tips or point me in the right direction.

I have an RG with a list of events that have a start date/time and an end date/time.

I want a user to be able to select days of the week or specific times that they are not available (maybe they have work or eat dinner at that time). For example Wednesdays 5:30pm - 6:30pm are unavailable. The RG should only display events that occur outside of the user’s ‘unavailable’ times.

Any ideas how to go about filtering the RG or storing the ‘unavailable times’ of the user? Thanks for any help I appreciate it!

I’d say something like this:

Database setup:

  1. Events Data Type: Ensure you have a data type for Events with fields for Start DateTime and End DateTime (both date and time).
  2. User Availability Data Type: Create a new data type called User Availability which will store the unavailable times for each user. This should include:
  • User (type: User; to link the availability to a specific user)
  • Day of the Week (type: text or option set; to store the day like Monday, Tuesday, etc.)
  • Start Time and End Time (type: time; to store the unavailable time slots)
    Note: It is probably worth it to experiment with date/time ranges.

Then use an input form on the user’s settings page where they can input their unavailable times. This could include dropdowns for selecting the day of the week and time inputs or sliders for defining the start and end times.

Then filter the events in the RG
You’ll need to add a condition that ensures none of the event times overlap with any of the times in the User Availability for the current user. Here’s an example of how the condition might look:

This Event's Start DateTime > Current User's User Availabilities's End Time or
This Event's End DateTime < Current User's User Availabilities's Start Time

If you experiment with date/time ranges, it will obviously be different.

Perhaps you also have to use custom states to deal with periods that cross from one day (and thus date) to the next, and/or time zone differences (if applicable).

If I’d built something like that myself I could probably be more detailed, but I haven’t, so I hope this puts you on the right path.

Yep I’m on board with creating a separate data type for ‘unavailable times’ that include a ‘day of the week’ field, ‘start time’ and ‘end time.’ I’d make a field on the User data type for a ‘List of unavailable times’ to store all their unavailable times.

My issue is figuring out how to filter the RG to only display events that do not fall within the ranges of unavailable times.

1 Like

Appreciate the time you took by the way! Very well written response

1 Like

Did you try to condition I suggested? Or did this one also not work?

I appreciate the suggestion but unfortunately it wouldn’t work because its only taking into account a single User availability and is more complicated when its a list of availabilities

In my filtering UI, the user is able to select a time of the week that they are unavailable every week, rather than just a single unavailable start/end time. For example, “Wednesdays 5pm - 7pm”. Your conditional would work for a single wednesday 5pm - 7pm, but not for all wednesdays 5pm - 7pm.

Would an Intersect With work here? So take the two lists (making sure they are either both set to just days of the week, or both to dates; one of them will have to be transformed I suppose) and then use the Intersect with and ':count'=0 (or >0, depending on how you’re doing it) and then you should know.

Just thinking out loud. I haven’t tested it on my end.