# Date range arithmetic and parenthesis function

**URL:** <https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308>\
**Category:** Idea\
**Created:** [September 1, 2021, 4:46am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308 "2021-09-01T04:46:17Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayy](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jayy](https://forum.bubble.io/u/jayy)\
**Post date:** [September 1, 2021, 4:46am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/1 "2021-09-01T04:46:17Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/2/b/2b3d700e6922bcc42ccba3475fdc25808b597616.png)

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [September 1, 2021, 5:18am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/2 "2021-09-01T05:18:18Z")

</div>

> [@jayy](#):
>
> This is an API workflow, so I can’t use custom states to store intermediate values.

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

---

<div class="post-metadata">

**Author:** ![jayy](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jayy](https://forum.bubble.io/u/jayy)\
**Post date:** [September 1, 2021, 5:37am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/3 "2021-09-01T05:37:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [September 1, 2021, 7:02pm UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/4 "2021-09-01T19:02:27Z")

</div>

> [@jayy](#):
>
> it’ll be harder to do it on a date range

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

---

<div class="post-metadata">

**Author:** ![jayy](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jayy](https://forum.bubble.io/u/jayy)\
**Post date:** [September 2, 2021, 6:51am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/5 "2021-09-02T06:51:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![austindesignpayne](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@austindesignpayne](https://forum.bubble.io/u/austindesignpayne)\
**Post date:** [November 30, 2021, 12:05am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/6 "2021-11-30T00:05:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![austindesignpayne](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@austindesignpayne](https://forum.bubble.io/u/austindesignpayne)\
**Post date:** [November 30, 2021, 12:07am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/7 "2021-11-30T00:07:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jayy](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jayy](https://forum.bubble.io/u/jayy)\
**Post date:** [November 30, 2021, 6:07am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/8 "2021-11-30T06:07:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [November 30, 2021, 8:29am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/9 "2021-11-30T08:29:59Z")

</div>

> [@austindesignpayne](#):
>
> What exactly do you mean by parameter in this instance?

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](https://manual.bubble.io/core-resources/api/workflow-api#api-event-endpoint)

> [@austindesignpayne](#):
>
> How would I do this though?

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.

> [@austindesignpayne](#):
>
> Also, I’ve looked around quite a bit here in the forum. Haven’t you created an entire booking/scheduling template?

I have. There are a couple of [my templates](https://bubble.io/contributor/boston85719-1526389052011x995012978091836000) that use the same scheduling function I put together for the [Calendly Clone Template](https://bubble.io/template/scheduleme---calendly-clone-1605774848808x635127424087752700).

> [@austindesignpayne](#):
>
> That has got to be ridiculous/painful to do work arounds for an entire 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.

---

<div class="post-metadata">

**Author:** ![austindesignpayne](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@austindesignpayne](https://forum.bubble.io/u/austindesignpayne)\
**Post date:** [December 1, 2021, 1:05am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/10 "2021-12-01T01:05:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [December 1, 2021, 6:15am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/11 "2021-12-01T06:15:27Z")

</div>

> [@austindesignpayne](#):
>
> Is it possible to manipulate a date range (split, shorten, or other)

Yes it is.

> [@austindesignpayne](#):
>
> Can a date range only contain another date range or date

It can be both

> [@austindesignpayne](#):
>
> 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.

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.

> [@austindesignpayne](#):
>
> What data type should the estimated duration be to make this work if possible?

Duration is a number, so an integer.

---

<div class="post-metadata">

**Author:** ![austindesignpayne](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@austindesignpayne](https://forum.bubble.io/u/austindesignpayne)\
**Post date:** [January 26, 2022, 11:35pm UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/12 "2022-01-26T23:35:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [January 27, 2022, 8:04am UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/13 "2022-01-27T08:04:52Z")

</div>

> [@austindesignpayne](#):
>
> Have you came across this issue

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.

---

<div class="post-metadata">

**Author:** ![austindesignpayne](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@austindesignpayne](https://forum.bubble.io/u/austindesignpayne)\
**Post date:** [February 2, 2022, 5:48pm UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/14 "2022-02-02T17:48:28Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [February 3, 2022, 12:04pm UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/15 "2022-02-03T12:04:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![grace.hong](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/grace.hong/32/109318_2.png) [@grace.hong](https://forum.bubble.io/u/grace.hong)\
**Post date:** [April 29, 2022, 8:20pm UTC](https://forum.bubble.io/t/date-range-arithmetic-and-parenthesis-function/167308/16 "2022-04-29T20:20:31Z")

</div>

Hi all - We recently released an experimental features UI that has a development version of parentheses. Learn more [here](http://forum.bubble.io/t/introducing-experimental-features/204501)! Hope you all have the opportunity to start playing around with it and help us iterate to make it better!
