mirror of
https://github.com/jbranchaud/til
synced 2026-01-05 08:08:02 +00:00
Add Constructing A Range Of Dates as a postgres til
This commit is contained in:
17
postgres/constructing-a-range-of-dates.md
Normal file
17
postgres/constructing-a-range-of-dates.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Constructing A Range Of Dates
|
||||
|
||||
PostgreSQL offers a number of range types including the `daterange` type.
|
||||
This can be constructed using the `daterange()` function with two strings
|
||||
representing the lower and upper bounds of the date range respectively.
|
||||
|
||||
```sql
|
||||
> select daterange('2015-1-1','2015-1-5');
|
||||
daterange
|
||||
-------------------------
|
||||
[2015-01-01,2015-01-05)
|
||||
```
|
||||
|
||||
The lower bound is inclusive -- indicated by the `[` character -- and the
|
||||
upper bound is exclusive -- indicated by the `)` character.
|
||||
|
||||
[source](http://www.postgresql.org/docs/current/static/rangetypes.html)
|
||||
Reference in New Issue
Block a user