日期:2014-05-17  浏览次数:20878 次

Oracle时间问题
如何给最大时间添加一分钟?下面语句要如何修改?

select to_date((select max(c_createtime) from t_templateChildtemp),'yyyy-mm-dd hh24:mi')+(1/1440) from dual;

------解决方案--------------------
如果本来就是date类型的话,直接找最大的加1/1440
SELECT MAX (c_createtime)+ (1/1440)
FROM t_templatechildtemp
------解决方案--------------------
SQL code

SQL> SELECT to_char(to_date('2011-11-07 23:42:54','yyyy-mm-dd hh24:mi:ss') + (1/1440),'yyyy-mm-dd hh24:mi:ss')  as new FROM dual;

NEW
--------------------------------------
2011-11-07 23:43:54

SQL>

测试结果

------解决方案--------------------
探讨
SQL code

SQL> SELECT to_char(to_date('2011-11-07 23:42:54','yyyy-mm-dd hh24:mi:ss') + (1/1440),'yyyy-mm-dd hh24:mi:ss') as new FROM dual;

NEW
--------------------------------------
2011-11-07……

------解决方案--------------------
SQL code
SELECT MAX(c_createtime)+1/1440 time
  FROM t_templatechildtemp