List of Dates Between Dates

Hi all!

I’m building a boat syndication app that allows boat shareholders to book days on their boat.

Is there a quick Javascript snippet I can use to create a list of all dates between the Start and End date of the booking?

E.g.

  • Start 24th
  • End 28th
  • List of days between = 25th, 26th, 27th.

I’ve done this without code, but it has added quite a few columns to my table and isn’t really scalable…
I feel like there’s a short Javascript snippet of code that would solve this for me?

Any help would be much appreciated!

Cheers,
Marco :clinking_glasses:

I would use a Helper Table to dynamically generate the list. Is there a known maximum number of days?

1 Like

Thanks for the quick response Darren!

What’s a Helper Table?
And how would I implement it?

As for the max duration, I don’t expect a single booking to exceed 7 days, but there’s no hard limit so I wanted to build in redundancy incase someone wanted to book 2-3 weeks onboard.

Gimme 10-15 mins, I’ll make a quick video.

1 Like

Legend, much appreciated!

1 Like

Here you go…

Also, just to answer this question…

Have a read of the below thread:

5 Likes

Very clear explanation Darren, appreciate you taking the time to explain.

I’ll experiment now and see how I go, seems like a solid alternative to my column overload :+1:

1 Like

Hi Darren, looks like your solution works quite well for my use-case.

Since the Start and End dates are user-specific columns on another form, I was able to simplify your solution even further by replacing the user-specific Start & End dates in the Helper table with a Single Value column that pulls from the form itself… If that makes sense? :sweat_smile:

Anyhow, thanks your help!

Yep, that makes perfect sense. I was just giving you a self-contained example.

Also, you’ve probably also figured out that the first 3 columns aren’t strictly necessary. You could replace those 3 with a single Number type column, and number the rows manually. I just do it the way I showed in the video out of habit. I also think it’s a bit more elegant :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.