Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96685 > unrolled thread
| Started by | Michiel Overtoom <motoom@xs4all.nl> |
|---|---|
| First post | 2015-09-16 17:01 +0200 |
| Last post | 2015-09-16 17:01 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: datetime.datetime.today() Michiel Overtoom <motoom@xs4all.nl> - 2015-09-16 17:01 +0200
| From | Michiel Overtoom <motoom@xs4all.nl> |
|---|---|
| Date | 2015-09-16 17:01 +0200 |
| Subject | Re: datetime.datetime.today() |
| Message-ID | <mailman.646.1442415769.8327.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web