This function is pretty much similar to SQL datepart function. Syntax is given below. This was taken from the below URL.
EXTRACT ({ YEAR | MONTH | DAY | HOUR | MINUTE | SECOND }
| { TIMEZONE_HOUR | TIMEZONE_MINUTE }
| { TIMEZONE_REGION | TIMEZONE_ABBR }
FROM { date_value | interval_value } )
| { TIMEZONE_HOUR | TIMEZONE_MINUTE }
| { TIMEZONE_REGION | TIMEZONE_ABBR }
FROM { date_value | interval_value } )
You can take year, month and day separately using this function.
extract(YEAR FROM DATE '2011-07-20') | would return 2011 |
extract(MONTH FROM DATE '2011-07-20') | would return 7 |
extract(DAY FROM DATE '2011-07-20') | would return 20 |
No comments:
Post a Comment