Forum Academy Marketplace Showcase Pricing Features

Generate a Date for a given day of the week

Hello,

I need to generate a list of entries in the database, each dated on a given day of the week.

Say I have period of time 4-Feb-22 to 18-Apr-22 and I want to generate a new thing on the database for every week within this time period, dated each Wednesday.

So the first entry will be on Wed. 9-Feb-22, etc. 10x times until Wed. 13-Feb-22.

I’m not really interested in a calendar UI element or anything like that, but only want to create some entries with a weekly date.

I’ve seen a couple of plugins out there on the forum but they mostly are UI plugins, some relying on a repeating group and so on.

I really just want to be able to schedule a backend workflow recursively to create N entries on a given day D.

What method or plugin would you advise for this purpose?

Okay I believe I’ve drafted the correct answer for this.

  1. First I use the Date & Time Toolkit Date & Time Toolkit Plugin | Bubble which, kind of forces me to work from the UI, which isn’t ideal as I wanted to do that from the server—but let’s adapt.

  2. Create a Data Type Weekdays, with each day of the week starting from Sunday to Saturday, index 0 to 6 respectively. This is needed to calculate the number of days to add to the start date to arrive at the first date of the desired day of occurrence.

  3. Set a Start Date and End Date date-picker, and a weekday drop down on the UI.

  4. Calculate the number of days to add to the start date to arrive at the following desired weekday. Formula is IF Start Date Day’s Value > Target Day’s Value THEN Target Day’s Value - Start Date’s Day’s Value +7 ELSE Target Day’s Value - Start Date’s Day’s Value END. In Bubblish this translate as a group with a number type of content, data source = drop down’s chosen day’s value - Start Date’s value:extract day and do a conditional for the other half of the logical clause.

  5. Create yet another group to calculate the true start date of the recurrence, i.e. Start Date + N Days where N is the number of days calculated in the previous group.

  6. Throw that date into the SplitDateRange element of the plugin and the rest should be a piece of cake.

The bad news is that in order to do this, I need UI, hence I cannot schedule this as an API workflow from the backend.

Conclusions.
A. Would be good if plugins had both front and back end applications.
B. Would be good if bubble had the a way to subtract days.
C. Would be good if bubble had a way to store variables without having to build groups on UI.

This topic was automatically closed after 70 days. New replies are no longer allowed.