How do I change all the information in the database at a specific time?

I’m making an application where the user has daily activities, they can be completed or not, I want that at midnight, all completed activities in the database change to not completed. How do I do that?

My app:

Run a workflow, at midnight, which changes all completed activities in the database to not completed.

you mean a backend workflow right?

Of course… specifically, an API Workflow (or maybe a Recurring Event).


I put it here in the on page load event, does +1 day represent the next day or +24 hours?

does +1 day represent the next day or +24 hours?

Neither…

+1 days increments the Date by 1 day (which most of the time means it adds 24 hours, but that’s not always the case).

But I’m not sure what your screenshot has to do with your question, nor my answer…

You’re searching for Exercises which have been modified after tomorrow - which is impossible, so will always return no results.

In any case, as I previously mentioned, you can’t do this on a page workflow, you need to schedule an API workflow to run at the given time, and make the changes there.

If you don’t know how to do that, I’d suggest you start with reading the Bubble manual to learn the basics.

So basically, every activity in your database will be reseted to Completed = NO.

  1. Create a backendworkflow called “Reset”
  2. Insert an action inside it to “Make changes to a list of things”. The list will be a Search for you activities constrained by Completed = YES.
  3. In the second step, reschedule this same workflow to run in Current Date/Time +24 hours :rounded down to date

Now, create a button somewhere in your app to start this backend workflow by scheduling it to Current Date/Time + 24 hours :round down to date. Once you start it, it will keep rescheduling itselft forever…

For WU reasons, how i usually approach this ‘resetting’ is to actually skip the reset all together and use frontend formatting.
I would change the ‘Checked’ field to a date instead of a yes/no.
The conditional 'This Exercise’s checked > Current date time rounded down to day" can substitute the yes/no field, and it will skip the need to spend 1000s of WUs on resetting all exercises every day, and it applies with no delay, at midnight on the dot, on all exercises.

This cant be applied to all use-cases, but in this simple scenario it works quite well.

2 Likes

Excellent tip!

1 Like

This is a much smarter solution than what I was trying to do, thank you for helping me.

1 Like