Skip to content

Commit e1b9a6a

Browse files
committed
Add Constructing A Range Of Dates as a postgres til
1 parent 1fdbe95 commit e1b9a6a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ _310 TILs and counting..._
132132
- [Checking The Type Of A Value](postgres/checking-the-type-of-a-value.md)
133133
- [Compute Hashes With pgcrypto](postgres/compute-hashes-with-pgcrypto.md)
134134
- [Configure The Timezone](postgres/configure-the-timezone.md)
135+
- [Constructing A Range Of Dates](postgres/constructing-a-range-of-dates.md)
135136
- [Count Records By Type](postgres/count-records-by-type.md)
136137
- [Create A Composite Primary Key](postgres/create-a-composite-primary-key.md)
137138
- [Create hstore From Two Arrays](postgres/create-hstore-from-two-arrays.md)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Constructing A Range Of Dates
2+
3+
PostgreSQL offers a number of range types including the `daterange` type.
4+
This can be constructed using the `daterange()` function with two strings
5+
representing the lower and upper bounds of the date range respectively.
6+
7+
```sql
8+
> select daterange('2015-1-1','2015-1-5');
9+
daterange
10+
-------------------------
11+
[2015-01-01,2015-01-05)
12+
```
13+
14+
The lower bound is inclusive -- indicated by the `[` character -- and the
15+
upper bound is exclusive -- indicated by the `)` character.
16+
17+
[source](http://www.postgresql.org/docs/current/static/rangetypes.html)

0 commit comments

Comments
 (0)