I want to split the days between 2 given dates into a specific batch size to make my api call easy. I am currently using this to split it on a monthly basis. However, need to split it further depending on user input batch size and get the start and end_date.
For eg:
start_date : 2020-01-01
end_date : 2020-01-31
batch: 10
Output:
start: 2020-01-01
end :2020-01-10
start : 2020-01-11
end: 2020-01-20
start : 2020-01-21
end: 2020-01-30
start: 2020-01-31
end: 2020-01-31
I am doing this: what changes should I make?
from dateutil import rrule, parser
start = parser.parse('Jan 21 2020')
end = parser.parse('Oct 30 2020')
date_list = [start]
date_list.extend(list(rrule.rrule(rrule.MONTHLY, bymonthday=(-1,1), dtstart=start, until=end)))
date_list.append(end)
print(date_list)