Can we subtract Date time range with another?

Hello Everyone :wave:

Is it possible to subtract the Date time range from another?

For example, I’ve a date range like this
[“Nov 30, 2023 10:30 am”,“Nov 30, 2023 14:00 pm”]

Can we subtract another date range like [“Nov 30, 2023 11:30 am”,“Nov 30, 2023 12:00 pm”] from the above range :point_up_2:
Generate two time ranges like this :point_down:
[“Nov 30, 2023 10:30 am”,“Nov 30, 2023 11:30 pm”] and
[“Nov 30, 2023 12:30 am”,“Nov 30, 2023 14:00 pm”]

If yes, any idea how to do that?

Thanks a lot for your help :pray:

Using a custom javascript function would work quite well here, as this would probably be just a few lines of code.
But you can also set this up with native bubble with a few workflow steps.

Is it guaranteed that Date Range B is always fully contained by Date Range A? Or could it be partially contained? Or could it also be fully outside?

If the latter two scenarios are allowed, what would you want your output to look like?

1 Like

Hi @mdburhan3,

If I understand correctly, you have two date ranges - one of which is entirely contained within the other - and you want to effectively “remove” the contained date range from the containing date range, thereby resulting in two new date ranges.

Yes, that’s totally possible; and in fact, it’s quite easy. You might want to familiarize yourself with Bubble’s built-in date range operations.

For the specific scenario you describe, you’d simply create two new ranges as follows:

  • First range would be containing_range:start <- range -> contained_range:start
  • Second range would be contained_range:end <- range -> containing_range:end

You’d probably want to first check to ensure one range is entirely contained within the other. Bubble has lots of super handy and efficient date related operations.

1 Like

Thanks a lot @sudsy
I will try this & Let you know

Thanks for your reply
Yes it is always fully contained

I will try to implement sudsy response first

Thanks a lot It works :pray: