Forum Academy Marketplace Showcase Pricing Features

Calculate the time difference between dates in a RepeatingGroup

Hello there,
how do I calculate the time difference between two dates in a RepeatingGroup?
(Date of registration 1 - Date of registration 2)
Tks!

@airton

thank you but
when I create the TEXT field the PARENT GROUP does not appear

I’m inside a repeatingGroup and I have only one date. this date will be repeated for another record…
I can’t see the second date

That is because your question was focused on the way to do it with a repeating group but the setup provided in the example doesn’t make use of a repeating group.

In order to know the difference between the two dates in a repeating group is to first extract the values from the repeating group if you know the values and the position (My assumption here is you have a repeating group used because you have more than just two dates and the comparison should allow a user to select which dates from the repeating group they want to compare).

In this I add a button to the repeating group that lets people select the date and set a custom state to hold the date (you’d need two custom states)…then outside of the repeating group you can add some text element that would compare the two selected dates.

If you only have two dates in the repeating group, and that is all there ever will be, you should rethink the use of the repeating group to make it easier to reference the data values for comparison purposes.

1 Like

Bubble doesn’t put duplicated content into the same list of values, so two dates that are the same are treated as one.

1 Like

thanks everyone, but i need to calculate the difference between two dates. See the example below.

That is a complex undertaking and one that wouldn’t be easy enough to give detailed instructions via the forum, especially without understanding the expected user experience regarding how these get populated.

But, you would need to use the plugin called ‘Orchestra’ to run workflows in the different cells as well as another called ‘Satellite’ to allow the different cells to reference the others value…alternatively you’d need to set up your database structure in such a way that you can easily reference the preceding cells values by way of organizing the data into ‘lists’ that each item can be tracked (with that in mind you may look at using the list shifter plugin to track the items in the list).

1 Like

I think the bdk RG extractor tool is perfect for this use case and I only say that ad I have completed this exact use case using that plugin

That said, list shifter probably does this too, I’m just not sure.

I’m not familiar with the bdk RG extractor tool in terms of having used it but I think it does a lot of what Orchestra does, but maybe need to use the combination of Orchestra and Satellite to get all the same functionalities.

The list shifter plugin from my view isn’t as much focused on repeating groups but more focused on ‘data storage’ and ‘processing’…however, the List Popper plugin is great for doing some workflow actions on lists and removing items as you do the workflows. I’ve used List Popper for some shopping cart stuff.

Is it always the difference between a value in the current list item and previous list item that you need, or might you need the difference between 2 arbitrary items in the list?

-Steve

I trying to do this …

Yes, I’ve read this thread and have seen all 3 posts of that screenshot.

It sounds like you’re simply asking how to reference the previous cell’s Thing from the current cell.

If that’s correct, then that’s simple to achieve (although not necessarily obvious) and does not require any plugins.

The solution is to add a hidden input to the RG to hold the index of the previous item in the list.


 
 

Then you can get a reference to the previous list item’s Thing and access any of its fields. Here, I’m just calculating the difference in price between the current item and previous item…


 
 

-Steve

2 Likes

That’s cool, I’ll try to do it and give you a return

:muscle: nice work!

2 Likes

It worked! thank you very much, great tip. My best! Airton