From 287316b5064881c191cd33379e5294f5013d561b Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 2 Jul 2015 08:45:41 -0500 Subject: [PATCH] Add Intervals Of Time By Week as a postgres til. --- README.md | 1 + postgres/intervals-of-time-by-week.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 postgres/intervals-of-time-by-week.md diff --git a/README.md b/README.md index d54131e..6c7d669 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Extracting Nested JSON Data](postgres/extracting-nested-json-data.md) - [Fizzbuzz With Common Table Expressions](postgres/fizzbuzz-with-common-table-expressions.md) - [Generate Series Of Numbers](postgres/generate-series-of-numbers.md) +- [Intervals Of Time By Week](postgres/intervals-of-time-by-week.md) - [Limit Execution Time Of Statements](postgres/limit-execution-time-of-statements.md) - [List All Columns Of A Specific Type](postgres/list-all-columns-of-a-specific-type.md) - [String Contains Another String](postgres/string-contains-another-string.md) diff --git a/postgres/intervals-of-time-by-week.md b/postgres/intervals-of-time-by-week.md new file mode 100644 index 0000000..731ad60 --- /dev/null +++ b/postgres/intervals-of-time-by-week.md @@ -0,0 +1,18 @@ +# Intervals Of Time By Week + +It is pretty common to use hours or days when creating a Postgres +interval. However, intervals can also be created in week-sized chunks + +```sql +> select '2 weeks'::interval; + interval +---------- + 14 days +(1 row) + +> select make_interval(0,0,7,0,0,0,0); + make_interval +--------------- + 49 days +(1 row) +```