date_part is a function to extract subfields of a value, which has to be one of the following datatypes: date, timestamp or interval.
This function has two argument:
- subfield is the part of the value we want to extract
- source represents the value from which we want to extract the subfield
Examples:
SELECT
date_part('month', '2/20/2019'::date);
date_part
-----------
2
(1 row)
SELECT
date_part('second', '2/20/2019 12:5:34'::timestamp);
date_part
-----------
34
(1 row)
SELECT
date_part('day', '6 years 5 months 4 days'::interval);
date_part
-----------
4
(1 row)
No comments:
Post a Comment