F.12. daterange_inclusive — upper bound-inclusivedaterange | ||||
|---|---|---|---|---|
| Prev | Up | Appendix F. Additional Supplied Modules and Extensions Shipped inpostgrespro-std-17-contrib | Home | Next |
F.12. daterange_inclusive — upper bound-inclusivedaterange#
daterange_inclusive is an extension to the built-indaterange range type. By default,daterange excludes the upper bound of the range —[), whereasdaterange_inclusive does not —[]. Other than the covered range bound, there are no other differences betweendaterange anddaterange_inclusive.
This module is considered“trusted”, that is, it can be installed by non-superusers who haveCREATE privilege on the current database.
F.12.1. Rationale#
At times, it is more convenient to output date ranges with inclusive upper bounds. For example, it may apply to employees' absences. If an employee is absent from January 1, 2025, to January 10, 2025, using thedaterange range type will prevent the database from outputting this date range in its entirety. In such cases, you would need to manually subtract one day from the output. Thedaterange_inclusive extension addresses this issue.
F.12.2. Example Usage#
CREATE EXTENSION daterange_inclusive; SELECT daterange('[2024-01-01,2024-06-01]'); daterange ------------------------- [2024-01-01,2024-06-02) SELECT daterange_inclusive('[2024-01-01,2024-06-01]'); daterange_inclusive ------------------------- [2024-01-01,2024-06-01]