Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96685
| 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 | <motoom@xs4all.nl> |
| 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 <motoom@xs4all.nl> |
| In-Reply-To | <CANc-5Uz7bON+aXG1vmOpuVAqga9v8h+tLBjvWtDbWo6hF3OXTw@mail.gmail.com> |
| Date | Wed, 16 Sep 2015 17:01:39 +0200 |
| Content-Transfer-Encoding | quoted-printable |
| References | <CANc-5Uwa0q0pgfBGfHLWyFzQYzS0cBhna+ARyPN9RJ2j8ar7Bw@mail.gmail.com> <CAGuvt93ys+iOr7unUOXP0rFRkE_AGo5FWEn2RkGn9NyfjfH7gA@mail.gmail.com> <CANc-5Uz7bON+aXG1vmOpuVAqga9v8h+tLBjvWtDbWo6hF3OXTw@mail.gmail.com> |
| To | Pyton List <python-list@python.org> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.646.1442415769.8327.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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 = datetime.datetime.today() >>> a datetime.datetime(2015, 9, 16, 16, 57, 45, 150069) >>> b = datetime.date.today() >>> a == b False >>> a.date() datetime.date(2015, 9, 16) >>> a.date() == b True Greetings,
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: datetime.datetime.today() Michiel Overtoom <motoom@xs4all.nl> - 2015-09-16 17:01 +0200
csiph-web