Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '16,': 0.03; '16)': 0.09; 'subject:()': 0.09; '57,': 0.16; 'from:addr:xs4all.nl': 0.16; 'received:194.109': 0.16; 'received:194.109.24': 0.16; 'received:xs4all.nl': 0.16; 'subject:skip:d 20': 0.16; 'comparing': 0.18; '>>>': 0.20; 'function,': 0.22; 'bit': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'compare': 0.27; 'once.': 0.29; 'date:': 0.31; 'skip:d 20': 0.34; 'done': 0.35; 'false': 0.35; 'expected': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'charset:us- ascii': 0.37; 'to:addr:python.org': 0.40; 'header:Message-Id:1': 0.61; 'greetings,': 0.61; 'received:194': 0.61; 'day,': 0.65; 'received:nl': 0.72; 'same,': 0.91 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: datetime.datetime.today() From: Michiel Overtoom In-Reply-To: Date: Wed, 16 Sep 2015 17:01:39 +0200 Content-Transfer-Encoding: quoted-printable References: To: Pyton List X-Mailer: Apple Mail (2.2104) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442415769 news.xs4all.nl 23786 [2001:888:2000:d::a6]:53975 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96685 This bit me once. I was comparing a date to a datetime, both = representing the same day, so I expected them to be the same, but I was = wrong. What I should have done was extracting the date of the datetime = with the .date() function, and only then compare it to the other date: >>> import datetime >>> a =3D datetime.datetime.today() >>> a datetime.datetime(2015, 9, 16, 16, 57, 45, 150069) >>> b =3D datetime.date.today() >>> a =3D=3D b False >>> a.date() datetime.date(2015, 9, 16) >>> a.date() =3D=3D b True Greetings,