Skip to content
All lessons

Tech Insights

You don't need a hacky snippet to manipulate dates into the a specific moment, such as EOD. datetime.datetime.combine can d...

You don't need a hacky snippet to manipulate dates into the a specific moment, such as EOD. datetime.datetime.combine can do that for you as it receives three parameters: date (can be datetime too), time and tzinfo , the latter being an optional argument. The following snippet will put a given date into EOD:

``` from datetime import datetime, time

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) ```

Shared by

  • Python

Book a call

Lessons like this one
shape how we build.

Tell us what you’re building. In one call, we’ll show you how our team would approach it.

Tell us what you’re building, and we’ll show you how we’d approach it.

Still prefer the good old email? Contact us