Skip to content

Commit 87c57c7

Browse files
committed
Add Day Of Week By Name For A Date as a postgres til
1 parent ab13092 commit 87c57c7

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77
warrant a full blog post. These are mostly things I learn by pairing with
88
smart people at [Hashrocket](http://hashrocket.com/).
99

10-
_316 TILs and counting..._
10+
_317 TILs and counting..._
1111

1212
---
1313

@@ -137,6 +137,7 @@ _316 TILs and counting..._
137137
- [Create A Composite Primary Key](postgres/create-a-composite-primary-key.md)
138138
- [Create hstore From Two Arrays](postgres/create-hstore-from-two-arrays.md)
139139
- [Creating Conditional Constraints](postgres/creating-conditional-constraints.md)
140+
- [Day Of Week By Name For A Date](postgres/day-of-week-by-name-for-a-date.md)
140141
- [Day Of Week For A Date](postgres/day-of-week-for-a-date.md)
141142
- [Default Schema](postgres/default-schema.md)
142143
- [Defining Arrays](postgres/defining-arrays.md)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Day Of Week By Name For A Date
2+
3+
In [Day Of Week For A Date](day-of-week-for-a-date.md), I explained how to
4+
determine what day of the week a date is as an integer with PostgreSQL. This
5+
used the `date_part()` function. By using the `to_char()` function with a
6+
date or timestamp, we can determine the day of the week by name (e.g.
7+
Monday). For instance, to determine what day today is, try a statement like
8+
the following:
9+
10+
```sql
11+
> select to_char(now(), 'Day');
12+
to_char
13+
-----------
14+
Sunday
15+
```
16+
17+
The `Day` part of the second argument is just one of many template patterns
18+
that can be used for formatting dates and times.
19+
20+
See [Data Type Formatting
21+
Functions](http://www.postgresql.org/docs/current/static/functions-formatting.html)
22+
in the Postgres docs for more details.

0 commit comments

Comments
 (0)