How to filter by date field

Solved it using regular property filter and a datetime. For anyone that may find it useful:

def get_tomorrow_midnight() -> datetime:
    now = datetime.now()
    tomorrow = now + timedelta(days=1)
    midnight = datetime(tomorrow.year, tomorrow.month, tomorrow.day)
    return midnight
response = collection.query.hybrid(
            ...,
            filters=wq.Filter.by_property("published_at").less_than(
                get_tomorrow_midnight()
            ),
        )

May be worth adding something to the docs, as currently the only datetime filtering in the docs is displaying how to filter on weaviate’s meta timestamps, not user-defined ones (unless I missed it).

Cheers

1 Like