Hi, I need some help!
I have a script that creates a table showing the static quantity of a product in stock during a "from date" to a "to date", it looks like this:
Product |
FromDate |
ToDate |
Quantity |
1 |
2021-06-08 |
2021-10-14 |
20 |
1 |
2021-10-15 |
2021-11-10 |
25 |
1 |
2021-11-11 |
2022-02-04 |
27 |
1 |
2022-02-05 |
2022-02-23 |
4 |
But I need the script to add rows with year/month that fit into the range of each "FromDate" to "ToDate", still with the same stock quantity. And i also need a new column "QD" that shows the total of days in each month the product have been in stock, see example below. Is this possible to do?
Product |
FromDate |
ToDate |
Quantity |
YearMonth |
QD |
1 |
2021-06-08 |
2021-10-14 |
20 |
202106 |
23 |
1 |
2021-06-08 |
2021-10-14 |
20 |
202107 |
31 |
1 |
2021-06-08 |
2021-10-14 |
20 |
202108 |
31 |
1 |
2021-06-08 |
2021-10-14 |
20 |
202109 |
30 |
1 |
2021-06-08 |
2021-10-14 |
20 |
202110 |
14 |
Best regards/ Patric