ORCALE数据库内年份运算

2014-11-24 09:06:19 · 作者: · 浏览: 0
ORCALE 数据库内年份运算
表table1中有字断time1,如有2001,2003,2005,2006,2007年的数据,
如果要查询2007年全年的数据如下..
www.2cto.com
查询: select * from table1 where to_char(time1,'yyyy')='2007'
如果要查询某一天的...例如2007-09-09这一天的
select * from table1 where to_char(time1,'yyyy-mm-dd')='2007-9-9'
select * from table1 where time1=to_date('2007-9-9','yyyy-mm-dd')
如果要将2007年的年份加一年或两年...如下操作
www.2cto.com
update table1 set time1=to_date(replace(to_char(time1,'yyyy-mm-dd'),'2007','2009'),'yyyy-mm-dd')
where to_char(time1,'yyyy')='2007'
适用:会员制数据库...比如会员年显到期.要续年限的.....