diff --git a/README.md b/README.md index ef6fa73..242fb73 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_316 TILs and counting..._ +_317 TILs and counting..._ --- @@ -137,6 +137,7 @@ _316 TILs and counting..._ - [Create A Composite Primary Key](postgres/create-a-composite-primary-key.md) - [Create hstore From Two Arrays](postgres/create-hstore-from-two-arrays.md) - [Creating Conditional Constraints](postgres/creating-conditional-constraints.md) +- [Day Of Week By Name For A Date](postgres/day-of-week-by-name-for-a-date.md) - [Day Of Week For A Date](postgres/day-of-week-for-a-date.md) - [Default Schema](postgres/default-schema.md) - [Defining Arrays](postgres/defining-arrays.md) diff --git a/postgres/day-of-week-by-name-for-a-date.md b/postgres/day-of-week-by-name-for-a-date.md new file mode 100644 index 0000000..4a51d62 --- /dev/null +++ b/postgres/day-of-week-by-name-for-a-date.md @@ -0,0 +1,22 @@ +# Day Of Week By Name For A Date + +In [Day Of Week For A Date](day-of-week-for-a-date.md), I explained how to +determine what day of the week a date is as an integer with PostgreSQL. This +used the `date_part()` function. By using the `to_char()` function with a +date or timestamp, we can determine the day of the week by name (e.g. +Monday). For instance, to determine what day today is, try a statement like +the following: + +```sql +> select to_char(now(), 'Day'); + to_char +----------- + Sunday +``` + +The `Day` part of the second argument is just one of many template patterns +that can be used for formatting dates and times. + +See [Data Type Formatting +Functions](http://www.postgresql.org/docs/current/static/functions-formatting.html) +in the Postgres docs for more details.