You just need to filter the dates before your target date, and take the max:
import datetime
dates = [datetime.datetime(2020,10,10), datetime.datetime(2020,10,25), datetime.datetime(2020,11,2)]
target = datetime.datetime(2020,11,1)
res = max(date for date in dates if date < target)
print(res)
#2020-10-25 00:00:00
To answer the question in your comment: you can simply extract the dates from your data:
data = [{'start': datetime.datetime(2020,10,10)}, {'start': datetime.datetime(2020,10,25)}, {'start': datetime.datetime(2020,11,2)}]
dates = [d['start'] for d in data]
and continue the same way, or do it all in one line:
import datetime
data = [{'start': datetime.datetime(2020,10,10)}, {'start': datetime.datetime(2020,10,25)}, {'start': datetime.datetime(2020,11,2)}]
target = datetime.datetime(2020,11,1)
res = max(d['start'] for d in data if d['start'] < target)
print(res)
#2020-10-25 00:00:00
or, using an assignment expression (for Python >= 3.8) to avoid accessing the dict twice:
res = max(date for d in data if (date := d['start']) < target)
And to address your last comment, if you want to return the dict, you can use the same principle and give max
a custom key, a function that will return the value associated to 'start'
:
from operator import itemgetter
res = max((d for d in data if d['start'] < target), key=itemgetter('start'))
or equivalently, without importing itemgetter, by using a lambda for the key:
res = max((d for d in data if d['start'] < target), key=lambda d: d['start'])