from datetime import datetime, timedelta date_format = "%Y-%m-%d" start_date = datetime.strptime("2022-01-01", date_format) end_date = datetime.strptime("2022-02-01", date_format) date_difference = (end_date - start_date).days print(f"Start Date: {start_date}\nEnd Date: {end_date}\nDate Difference (in days): {date_difference}")
Output:
Start Date: 2022-01-01 00:00:00
End Date: 2022-02-01 00:00:00
Date Difference (in days): 31