Forum Discussion
Olivier_Maltais
Oct 18, 2023Copper Contributor
Create an interval of date
Hello, I would like to have a formula to have a date interval. I want that the cell looks like this: 2023/12/31 to 2024/01/06 I would like to use a formula to set all the week of the year like this...
PeterBartholomew1
Oct 18, 2023Silver Contributor
This takes Riny_van_Eekelen 's formula a step or two further, for better or worse!
I finished with the worksheet formula
= Weeksλ(baseDate, 26)
where Weeksλ is a Lambda function that returns one week intervals as text, here starting with 'baseDate' and returning 26 weeks. The function executes the steps
Weeksλ
= LET(
intervals, SEQUENCE(count, , base, 7) + {0, 6},
week, TEXT(intervals, "yyyy/mm/dd"),
BYROW(week, Concatλ)
)
Adding {0, 6} to the week starting dates spills dynamically to give start and end dates for each week. The TEXT function is applied to each date, returning dates in international format. BYROW takes the dates in pairs and concatenates them using Concatλ to insert the time interval using the preposition 'to' as the separator,
Concatλ
= TEXTJOIN(" to ", , w)
Of course, all this requires Excel 365.
PeterBartholomew1
Oct 18, 2023Silver Contributor
Showing various steps along the way ...