I
I
Ivan2022-02-07 16:05:35
Python
Ivan, 2022-02-07 16:05:35

How to compare a day of the month (now) with a specific day and month using python?

Hello. Python3 datetime.
Such a task: when you click on the button, you need to compare datetime.now() and if the day and month are greater than March 10 - fun1() , otherwise func2() .
Something terribly stupid. Can't compare day and month

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vindicar, 2022-02-07
@FSystem88

dtNow = datetime.datetime.now()
dtDeadline = datetime.datetime(dtNow.year, 3, 10) # 10 марта
if dtNow > dtDeadline:
    print("Дедлайн прошел")

K
Konstantin Nagibovich, 2022-02-07
@nki

dtNow = datetime.now()
dtTemp = datetime.date(year, month, day)

Is it further clear?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question