This condition always evaluates to True even if it’s the same day because it is comparing time.
from datetime import datetime
# ...
if date_num_posts < datetime.today():
How can I check if a date is the same day as datetime.today()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to just compare dates,
Or, obviously,
If you want to check that they’re the same date.
The documentation is usually helpful. It is also usually the first google result for
python thing_i_have_a_question_about. Unless your question is about a function/module named “snake”.Basically, the
datetimemodule has three types for storing a point in time:datefor year, month, day of monthtimefor hours, minutes, seconds, microseconds, time zone infodatetimecombines date and time. It has the methodsdate()andtime()to get the correspondingdateandtimeobjects, and there’s a handycombinefunction to combinedateandtimeinto adatetime.