Querying Date ranges in postgres
Last updated
Last updated
When we are trying to query a Date with an PostgresSQL query like:
You will notice your query in Postgres is not including the upper bond ie 2021-11-31.
Inorder to resolve this you can query it like below using DATE field with <= and >= operator. This will ensure both the dates are included in the upper bound and lower bound.
This query can be implemented in SQLAlchemy as following: