Date range arithmetic and parenthesis function

Seems like I can’t add 1 month to an end date, within a date range. (I can only do arithmetic on the start date)

This is an API workflow, so I can’t use custom states to store intermediate values.

A lot of limitations like this within the Bubble composer (is this what it’s called?). For a start, a parenthesis function would help greatly. Rather than making the order of operation strictly sequential.

No, but you can create a Parameter to hold the value

Make a Parameter called “start date” and have it be a type date and a Parameter called “end date” and make it a type date

When you schedule the backend workflow set the date Parameter values

1 Like

Thanks! I’ll try that.

But I’m wondering if it’s safer to have 2 fields instead - start date and end date.
In case I need to manipulate the dates in future, and it’ll be harder to do it on a date range?

Might be. Still possible to do, so I guess just a personal choice.

1 Like

Thanks! I guess I’ll play it safe and have 2 fields.

Hello there!

I am having this exact same issue. It seems silly to me that you can’t simply add hours (etc.) on both sides of the range operator.

I am a no-coder, so I struggle with terms that are not bubble’s “language”. What exactly do you mean by parameter in this instance? I take it you mean, set a value somewhere else that can be used in the expression. How would I do this though? Put an invisible input on a page that’s value is used?

Also, I’ve looked around quite a bit here in the forum. Haven’t you created an entire booking/scheduling template? That has got to be ridiculous/painful to do work arounds for an entire template.

Same issue for me here. Did you end up using fields? If so, how did you accomplish this?

I ended up using 2 date fields. Easier to perform any arithmetic.

1 Like

Parameter is Bubble language. It is part of the backend workflows “AKA API workflows”

https://manual.bubble.io/core-resources/api/workflow-api#api-event-endpoint

I would make a parameter called ‘start date’ and have it be a type data and a Parameter called ‘end date’ and make it a type data. When scheduling the backend workflow I would set the date parameter values.

I have. There are a couple of my templates that use the same scheduling function I put together for the Calendly Clone Template.

I wouldn’t consider them necessarily work arounds as it is just really working within the system Bubble has built. But yes, creating a functional booking/scheduling application that can do everything necessary for a production grade scheduling application including timezone aware is challenging.

1 Like

Maybe you can help me with this. It seems to be easy but I can’t get it to work.

I am trying to build a service app for my company. I have a recursive backend workflow that creates generates a date type called “day” each day 30 days out (I wanted to limit bookable days to 30 days out). This data type “day” has a field called “availability” that is a list of date ranges. When the “day” is generated there is only one date range -which is the whole service day’s availability. My plan is to have these date ranges manipulated by scheduled jobs thus changing/limiting availability.

When a client wants to book a service. I want to have a RG search “Days” and then filter “Day” by “availability” contains the estimated duration of the service (filter because you can’t use a list of Date Ranges as a constraint during a search) . Once the “day” is selected date ranges that are large enough to contain the job’s estimated duration would be shown. Then when the job is booked the date range is manipulated to close availability.

I guess I have these questions:

  1. Is it possible to manipulate a date range (split, shorten, or other).
  2. Can a date range only contain another date range or date?
  3. Is it possible to filter a data type (in this case “day”) by using a constraint that is a date range (“availability”) that “contains” an estimated duration.
  4. What data type should the estimated duration be to make this work if possible? (date range, date interval, numeric range, or other). I assumed date interval would be the one but I cant get it to work.

Yes it is.

It can be both

I would imagine it is. Just needs to ensure things are setup properly to do so. If the ‘Day’ is a date it is possible. If the ‘Day’ is a date range it is possible.

Duration is a number, so an integer.

Hi!

I am much farther along in my first app now. I am now learning how to use the api connector which has been a challenge as a no-coder. However, I’ve managed to build a successfull call to Google’s Duration Matrix api. However, I am having issues on a bubble backend api recursive workflow. I am able to estimate drive times and duration with no time_of_Departure. However, once I try to implement this, it no longer works. Its as if the Distance Matric api does not use the measurement of time that I am trying to pass -like there is a format issue. The documentation says that I am to specify the time as an integer in seconds since midnight, January 1, 1970 UTC. I’ve done this as:

Start time - minus arbitrary date/time formatted as seconds

Start time is a field of a date type, and is in the future. The arbitrary date time is Thu Jan 01 1970 12:00:00 GMT-0800 (Pacific Standard Time)

Have you came across this issue or am I missing something? Its seems like something small/easy.

Yes, it comes up often because dates are nothing more than a number of seconds since Jan 1 1970 12AM UTC.

Bubble uses milliseconds, while most other systems I’ve come across use seconds.

Interesting! I was able to get it using extract: Unix!

I am having trouble with doing something a thought would be very easy. In short, a list filtered by a list.

I have a list of Dates in a RG. I want to filter those dates using a custom state that holds a list of Date ranges.

In Layman’s terms, I way to filter out dates that are inside of the of any of those date ranges.

I can’t seem to get the operators at the correct times to make this to work. I figured it would be as simple as overlaps or contains point, etc.

Any help is appreciated!

I’ve accomplished it on the backend doing a recursive api workflow but it is a little slow and requires by to create a temporary thing. So, not ideal. Was hoping to do it “on the fly”.

Check out the list shifter plugin. Can do processing like that.

Hi all - We recently released an experimental features UI that has a development version of parentheses. Learn more here! Hope you all have the opportunity to start playing around with it and help us iterate to make it better!