postgresqlHow can I extract the month from a date in PostgreSQL?
To extract the month from a date in PostgreSQL, you can use the EXTRACT
function.
Example code
SELECT EXTRACT(MONTH FROM '2019-03-25') AS month;
Output example
month
-------
3
(1 row)
The EXTRACT
function takes two parameters, the part of the date you want to extract (in this case, MONTH
) and the date from which you want to extract it. In this example, the date is 2019-03-25
. The output of the code is the month, in this case 3.
Code explanation
EXTRACT
: function to extract a part of a dateMONTH
: part of the date to extract2019-03-25
: date from which to extract the month
Helpful links
More of Postgresql
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How do I set the PostgreSQL work_mem parameter?
- How can I use PostgreSQL with YAML?
- How can I retrieve data from PostgreSQL for yesterday's date?
- How do I install PostgreSQL and Zabbix on my system?
- How do I install and configure PostgreSQL on Ubuntu?
- How do I rename a table in PostgreSQL?
- How can I write a PostgreSQL query to retrieve JSON data?
- How can Zalando use PostgreSQL to improve its software development?
See more codes...