<p>You don't need a hacky snippet to manipulate dates into the a specific moment, such as EOD. <code>datetime.datetime.combine</code> can do that for you as it receives three parameters: <code>date</code> (can be <code>datetime</code> too), <code>time</code> and <code>tzinfo</code> , the latter being an optional argument. The following snippet will put a given date into EOD:</p>
<p>```
from datetime import datetime, time</p>
<p>date = datetime.strptime("2019-01-01", "%Y-%m-%d") # datetime.datetime(2029, 1, 1, 0, 0)
eod_date = datetime.combine(date, time.max) # datetime.datetime(2029, 1, 1, 23, 59, 59, 999999)
```</p>
By clicking “Accept cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage and assist in our marketing efforts. Check our privacy policies.
By clicking “Accept all”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage and assist in our marketing efforts. Check our privacy policies.