Oracle Extract Function

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 } )

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

Comments

Popular posts from this blog

Error message “User does not have send-as privilege.” when sending emails programmatically in CRM 2011