日期时间函数 extract()
1. 用途:
extract() 用于从一个date 或者interval 类型中截取到特定的部分。
2. Grammer:
EXTRACT(
{YEAR|MONTH|DAY|HOUR|MINUTE|SECOND}
|{TIMEZONE_HOUR|TIMEZONE_MINUTES|}
|{TIMEZONE_REGIN|TIMEZONE_ABBR}
)
-- 只可以从一个date类型数据中截取到year,month,day. date 类型的格式“yyyy-mm-dd”.
-- 只可以从一个timestamp with time zone 的数据类型中截取到timezone_region,timezone_hour,timezone_minutes
select extract(year from date '2014-08-26')
from dual ;
>> 2014
select extract(month from date '2014-08-26')
from dual ;
>> 8
select extract(day from date '2014-08-26')
from dual ;
>> 26
select extract(year|month|day|hour|minute from systimestamp)
from dual;
select extract(timezone_region from systimestamp)
from dual ;
note:
1. In english edtion ,dafault date format is 'dd-mon-yy'.
2. In Chinese edition , default date format is "26-8月-2014" or "26-8月-14"
3. systimestamp 系统时间戳。