- Extracting YEAR, MONTH and DAY from date
Earlier we were only able to extract day, year and month from
the date data type.
However now we can combine date with a date interval and extract
the needed portion from the result.
EXTRACT YEAR FROM DATE;
EXTRACT MONTH FROM DATE;
EXTRACT DAY FROM DATE;
Examples:
SELECT EXTRACT( YEAR FROM DATE);
2013
SELECT EXTRACT(MONTH FROM DATE '2013-12-11');
12
Extracting from combination of date and interval
SELECT EXTRACT ( MONTH FROM (DATE '2012-02-01' + INTERVAL '3'
MONTH));
5
No comments:
Post a Comment