您的位置:首页 > 数据库 > Oracle

How To Add Day, Hour, Minute, Second to a Date Value in Oracle

2012-05-04 11:05 477 查看
Add a day.
select to_date('02-22-2008 10:30:30','mm-dd-yyyy hh24:mi:ss') today,
to_date('02-22-2008 10:30:30','mm-dd-yyyy hh24:mi:ss')+1 next_day
from dual;
TODAY NEXT_DAY
------------------------- -------------------------
02-22-08 10:30:30 02-23-08 10:30:30

Add an hour.
select to_date('02-22-08 10:30:30','mm-dd-yy hh24:mi:ss') today,
to_date('02-22-08 10:30:30','mm-dd-yy hh24:mi:ss')+ 1/24 next_hour
from dual;
TODAY NEXT_HOUR
------------------------ ------------------------
02-22-08 10:30:30 02-22-08 11:30:30

Add a minute.
select to_date('02-22-08 10:30:30','mm-dd-yy hh24:mi:ss') today,
to_date('02-22-08 10:30:30','mm-dd-yy hh24:mi:ss')+ 1/(24*60) next_min
from dual;
TODAY NEXT_MIN
------------------------ ------------------------
02-22-08 10:30:30 02-22-08 10:31:30

Add a second.
select to_date('02-22-08 10:30:30','mm-dd-yy hh24:mi:ss') today,
to_date('02-22-08 10:30:30','mm-dd-yy hh24:mi:ss')+ 1/(24*60*60) next_sec
from dual;
TODAY NEXT_SEC
------------------------ ------------------------
02-22-08 10:30:30 02-22-08 10:30:31
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: