Adding days to a DateTime

I have an athlete / coach training platform where I need to schedule training workouts. One of the tricky aspects (bc of Bubble’s way of doing things) is calculating a date in the future.

I have a StartDate (could be any day within a week) then I need to add X days to this date so that I can arrive at the Sunday date of the week that contains the StartDate. I see that Extract Day gives me the type of info I need (Sunday: 0 - Saturday: 6, essentially an ENUM that maps a day of the week to number).

I’ve tried a few things but can’t seem to figure how to craft the magic bubble statement that take any given date (could be a sunday itself, in which case I would just use that value) and return me a DateTime of the Sunday for the week in which my date is contained.

StartDate - Can be any date
Result needed - The Sunday for the week in which the StartDate occurs

I’m using this in a recursive workflow so I can schedule week by week an athlete’s training schedule. So, I need to start my workflow on a Sunday for each week.

Something like: StartDate +Days: (6 - StartDate: Extract Day), but I can’t seem to enter a parenthesis or a simple number equation for the “6 - StartDate: Extract Day” part.

But, since I’m new to Bubble something so basic that would be brain dead simple in code literally takes me days of trial and error and reading forum posts to figure out. So, here again, I’m back to posting to the forum to unravel Bubble’s garbage backend feature…

Hopefully someone has a clue, thanks a ton!

Hi there, @deepdev… if I understand your post correctly, try using the :rounded down to operator, and round the date down to week. Doing that will give you the Sunday of the week in which the date occurs.

Hope this helps.

Best…
Mike

2 Likes

yep, i had to use this method thanks! i tried Arbitrary Text and tried to evaluate expressions with that “feature” and it didn’t work.

The docs suck

. Thanks a ton!

1 Like