Create date range using dates in 2 columns

Hi @bruno29a

Thank you for the below solution. Question, what if I have multiple start and end date? How can I create a date range. I tried the solution you provided, however, the node only reads the first row.

Continuing the discussion from List all days between 2 dates without using SQL/R snippet:

If you go this route, then it would likely require a loop for each date range. You would then need to append a new column for each iteration at loop end.

The @bruno29a approach would have the added benefit of being able to join in a calendar with holiday or vacation days into the dates before a “number of work days calculation” as well if you needed that kind of advanced capability in the future.

1 Like

Hi @jepavila , as @iCFO said, @bruno29a’s approach can be adapted using a straightforward loop. In fact a Table Row to Variable Loop, in place of the Table Row to Variable should be all that is required.

Achieving it without a loop is a little more convoluted, but can be done by calculating the number of rows required for each date range, creating rows and then calculating the individual dates for each row based on their offset from each starting date.

The attached contains Bruno29a’s original plus these two examples

List all days between 2 dates - multiple dates.knwf (42.2 KB)

2 Likes

Hi @takbb,

this is really helpful, thank you.

follow-up question, if I use loop end, is there a way I can count the number of rows pertaining to the date range?

Thanks in advance.

Jeffff

Hi @jepavila , with the loop method, you simply have a set of dates so you can’t then get the range-counts directly.

I’m not sure of your use case but if you just want to get the count for the number of days in each date range, the simplest way I can think of is to use the first couple of nodes I included in the non-loop method.

If you want to add those counts against each date in the loop, you could tack on the loop and then add this column from the associated loop variable inside the loop…

List all days between 2 dates - multiple dates 2.knwf (55.0 KB)

1 Like

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