Today I Learned

hashrocket A Hashrocket project

Ensure that date is in a range with ice cream cone

In cases when you have a daterange in postgres and you need to ensure that a date falls within that range, you can use Postgres's ice cream cone operator (@>).

dev=# select tsrange('2019-1-1', '2020-1-1') @> '2019-6-1'::timestamp;          
(1 row)
See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.