oracle 日期,时间函数 date,to_date,extract,to_timestamp,last_day,frist_day

oracle中extract()函数从oracle 9i中引入,用于从一个date或者interval类型中截取到特定的部分 

select to_date('2016-01-01 12:16:01','yyyy-mm-dd hh24:mi:ss') from dual

select date'2016-01-01' from dual 

select last_day(date'2016-01-01') from dual 

select first_day(date'2016-01-01') from dual 

to_char()函数恰好相反,是将对象类型转换为相应的字符类型:如:to_char(to_date(substr('2008-5-1',1,4)||'01-01'),yyyy-mm-dd));查询出来的将是一个字符类型. 

extract(day from dt2-dt1) day 

extract(hour from dt2-dt1) hour 

extract(minute from dt2-dt1) minute 

extract(second from dt2-dt1) second 

extract(month from dt2-dt1) month 

extract(year from dt2-dt1) year 

 
 
原文地址:https://www.cnblogs.com/xinheng-blog/p/5893829.html