Creating time periods from two dates for a list of objects
Data Table 1
Item 1 Start 01/05/21 End 06/15/21Â
Item 2 Start 03/20/21 End 09/24/21
Create a new data table 2:
Item 1 Start 01/05/21 End 01/31/21
Item 1 Start 02/1/21 End 02/28/21
Item 1 Start 03/1/21 End 03/31/21
Item 1 Start 04/1/21 End 04/30/21
Item 1 Start 05/1/21 End 05/31/21
Item 1 Start 06/1/21 End 06/15/21
Item 2 Start 03/20/21 End 03/31/21
Item 2 Start 04/1/21 End 04/30/21
Item 2 Start 05/1/21 End 05/31/21
Item 2 Start 06/1/21 End 06/30/21
Item 2 Start 07/1/21 End 07/31/21
Item 2 Start 08/1/21 End 08/31/21
Item 2 Start 09/1/21 End 09/24/21
Â
In reality there will be associated values that will also need to be calculated based upon these time periods, but I can hopefully deal with that as a step 2.Â
What I've managed to do is create the first and second item, in that I take the start date, use last day of month function, and then + 1 day to get me the start of the next period.Â
What I'm struggling with is how to structure it in such a way that I get the required output.
I understand I need to loop through to create all required entries.
I believe 'Item 1', 'Start', 'End' I need to define as keys?
Would I need to loop through the 'Add Record' function to add each row in turn into the database? Â
Other
3 replies