Python generating a list of dates between two dates

You can use pandas.date_range() for this: import pandas pandas.date_range(sdate,edate-timedelta(days=1),freq=’d’) DatetimeIndex([‘2019-03-22’, ‘2019-03-23’, ‘2019-03-24’, ‘2019-03-25’, ‘2019-03-26’, ‘2019-03-27’, ‘2019-03-28’, ‘2019-03-29’, ‘2019-03-30’, ‘2019-03-31’, ‘2019-04-01’, ‘2019-04-02’, ‘2019-04-03’, ‘2019-04-04’, ‘2019-04-05’, ‘2019-04-06’, ‘2019-04-07’, ‘2019-04-08′], dtype=”datetime64[ns]”, freq=’D’)

Pandas date_range to generate monthly data at beginning of the month

You can do this by changing the freq argument from ‘M’ to ‘MS’: d = pandas.date_range(start=”1/1/1980″, end=’11/1/1990′, freq=’MS’) print(d) This should now print: DatetimeIndex([‘1980-01-01’, ‘1980-02-01’, ‘1980-03-01’, ‘1980-04-01’, ‘1980-05-01’, ‘1980-06-01’, ‘1980-07-01’, ‘1980-08-01’, ‘1980-09-01’, ‘1980-10-01’, … ‘1990-02-01’, ‘1990-03-01’, ‘1990-04-01’, ‘1990-05-01’, ‘1990-06-01’, ‘1990-07-01’, ‘1990-08-01’, ‘1990-09-01’, ‘1990-10-01’, ‘1990-11-01′], dtype=”datetime64[ns]”, length=131, freq=’MS’, tz=None) Look into the offset aliases part of … Read more

Insert multiple records with a date range in MS Access

This is where DAO shines. It is so much faster to run a loop adding records than calling a Insert Into multiple times. Here is how: Public Function PopulateBokings() Dim rsBookings As DAO.Recordset Dim NextDate As Date Set rsBookings = CurrentDb.OpenRecordset(“Select Top 1 * From Bookings”) NextDate = Me!StartDate.Value While DateDiff(“d”, NextDate, Me!EndDate.Value) >= 0 … Read more