Today I Learned

hashrocket A Hashrocket project

Day Of Week For A Date

Given a date in PostgreSQL

> select '2050-1-1'::date;

you can determine the day of the week for that date with the date_part() function

> select date_part('dow', '2050-1-1'::date);

The days of week are 0 through 6, 0 being Sunday and 6 being Saturday.


See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.