What should I do to ask Python for the end of the month, a year from today?

Asked 2 years ago, Updated 2 years ago, 20 views

One year from today, I was able to request it using the dateutil library, but I don't know how to request the end of the month.
I would appreciate it if you could let me know if anyone knows.Thank you for your cooperation.

 from datetime import datetime, date, timedelta
from dateutil.relativedelta import relativedelta

dt=date.today()+relatedelta(month=1)

python

2022-09-30 19:26

1 Answers

(Reprinted from comments)

One year and a month later, the day before the beginning of the month,

dt=date.today()+relatedelta (years=1, months=1, day=1, days=-1) 

I wonder if that's the case.


2022-09-30 19:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.