postgresqlHow can I convert a PostgreSQL timestamp to a date?
To convert a PostgreSQL timestamp to a date, you can use the to_date function. This function takes a timestamp as an argument and returns a date. For example:
SELECT to_date('2020-04-30 12:34:56', 'YYYY-MM-DD HH24:MI:SS')
Output example
2020-04-30
The code above contains the following parts:
SELECT: This is a keyword used to select a value from a table.to_date: This is the function used to convert a timestamp to a date.'2020-04-30 12:34:56': This is the timestamp argument passed to theto_datefunction.'YYYY-MM-DD HH24:MI:SS': This is the format of the timestamp argument.
For more information, please refer to the PostgreSQL Documentation.
More of Postgresql
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL's "zero if null" feature?
- How do I use PostgreSQL and ZFS together?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I integrate PostgreSQL with Yii2?
- How do I use PostgreSQL variables in my software development project?
- How can I monitor PostgreSQL performance using Zabbix?
- How do I set up PostgreSQL Kerberos authentication?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
See more codes...