In the parse_datestring method in stac_fastapi/mongo/utilities.py, which is used for generating the MongoDB query dict, the input time is converted from a string to a python datetime object back to a string. This can only work when the datetime is stored as a string in the MongoDB. However, the recommended way is to store dates/times as datetime objects in the MongoDB. Using my MongoDB where the item's datetime property is stored as a datetime object, queries with datetime filtering always returns no result.
When replacing return dt.strftime("%Y-%m-%dT%H:%M:%SZ") by return dt, then the datetime filtering works for me.
In the
parse_datestring
method instac_fastapi/mongo/utilities.py
, which is used for generating the MongoDB query dict, the input time is converted from a string to a python datetime object back to a string. This can only work when the datetime is stored as a string in the MongoDB. However, the recommended way is to store dates/times as datetime objects in the MongoDB. Using my MongoDB where the item's datetime property is stored as a datetime object, queries with datetime filtering always returns no result.When replacing
return dt.strftime("%Y-%m-%dT%H:%M:%SZ")
byreturn dt
, then the datetime filtering works for me.