Hotte Guy
Hotte Guy

Reputation: 1

day & month parameters unfilled? (datetime)

I'm trying to figure out how to return the difference of time in between now and from the last minute of this year. I seem to be getting errors saying "Parameter 'day' unfilled" and "Parameter 'month' unfilled".

 from datetime import datetime
        rn = datetime.now()
        ny = datetime('2022, 12, 31, 23, 59')
        df = ny - rn
        print(df.total_seconds())

if anyone could help out with this that would be greatly appreciated!

Upvotes: 0

Views: 250

Answers (1)

Talon
Talon

Reputation: 1884

You used a single string as parameter, you'd have to either use strptime to parse the string, or otherwise get your actual numbers out of the string

datetime(2022, 12, 31, 23, 59)
datetime.strptime('2022, 12, 31, 23, 59', "%Y, %m, %d, %H, %M")

Upvotes: 1

Related Questions