How to get start and end date of month data from specific date in Python?
Use Pendulum module to solve Date time problems.
Install it using below command
pip install pendulum
Install it using below command
pip install pendulum
import pendulum dt = pendulum.datetime(2012, 9, 5) start = dt.start_of('month') print(start.to_datetime_string()) end = dt.end_of('month') print(end.to_datetime_string())
Output
2012-09-01 00:00:00 2012-09-30 23:59:59