Backend Workflow Date Parameter Negative?

Hi Everyone,

I am really sorry to post here but me and ChatGPT are running out of ideas. I am trying to pull the last seven days of weather from an API using the backend workflow and I just cannot get it to work. ChatGPT keeps trying to get me to use some negative value in the date, such as:

This Workflow's Date + days: (This Workflow's SubtractDays * -1)

and the issue is that Bubble won’t accept the -1 value in the backend Date category.

Here is how ChaptGPT sums up the issue:
Hi everyone,
I’m working on a backend recursive workflow that needs to process a specific date by decrementing it (subtracting one day at a time) with each recursive call. However, I’m running into issues with Bubble’s expression builder and its limitations.

Setup:

  1. I have a SubtractDays parameter that increments with each recursive call (e.g., 0 → 1 → 2, etc.).
  2. I’m trying to calculate the new date using Date + days: (SubtractDays * -1) to go backward in time.
  3. Unfortunately, Bubble doesn’t allow direct negation (* -1) or parentheses within expressions for the Date parameter in backend workflows.
  4. Attempts to calculate a negative value for SubtractDays or use an intermediary parameter like OffsetDays have led to inconsistent results.

What Happens:

  • SubtractDays increments correctly, but the calculated Date is inconsistent or doesn’t decrement as expected.
  • I’ve tried various approaches, including adding a separate parameter (OffsetDays) and precomputing negative days, but nothing seems to work reliably in the backend.

Question:

  • How can I reliably subtract days from a date in a recursive backend workflow?
  • Is there a known workaround for these limitations in the expression builder?

Any advice or insights would be greatly appreciated. Thanks!

I also include some screenshots of the issue. I’m also having the issue where everything is reporting at 4pm even though I am rounding to the nearest day but that is another issue…

can simplify your question, do you want to schedule 1 day before next time.

like i have a workflow for 29 jan 2025 , once it run i will make it run 28 feb 2025, then 27 mar 2025 ?

Can you make the date a “text” data type instead of “date”?

I want the workflow to start on todays date and then go backwards one day for the past 7 days. IE if today is Dec 28th, 2024 then the first entry would be Dec 27th, 2024, the second be Dec 26th, 2024, etc as it cycles through the index value to do this for 7 days. Does this make sense? Again thanks for any help and suggestions

I’d do it this way

set an api workflow with inputs:
current_date
end_date

then have a reschedule api workflow at the end which adds/minus 1 to the current_date’s date each time it runs

it repeats as long as current date is smaller than end date.

that gives you the flexibility to start at any date and then step up or down 1 day per repeat

also ensures the workflow ends if current date is larger than end date
you may want to also add a max limit to the iterations by limiting the inputs the user can add (in case they select wrong year for instance…)

you’d also want to set the api repeater step to fit with the rate limit of the api you’re using