【发布时间】:2010-09-28 16:45:26
【问题描述】:
我希望有人可以帮助我。
我想将一个月添加到数据库日期,但我想在最后的那些日子里防止两个跳过月份。
例如我可能有:
2009 年 1 月 31 日
我想得到
2009 年 2 月 28 日
而不是
2009 年 3 月 2 日
下一个日期是
2009 年 3 月 28 日
2009 年 6 月 28 日
等等。
oracle中是否有已经执行这种操作的函数?
编辑
是的。我想每个月将所有具有某种状态的记录复制到下一个(因此用户不必每个月再次输入 2,000 行)
我可以手动获取所有记录并更新日期(以命令的方式),但我宁愿让 SQL 完成这项工作。
类似:
insert into the_table
select f1,f2,f3, f_date + 30 /* sort of ... :S */ from the_Table where date > ?
但问题出现在最后一天。
在我必须编写这样的代码之前有什么想法吗?
for each record in
createObject( record )
object.date + date blabala
if( date > 29 and if februrary and the moon and the stars etc etc 9
end
update.... et
编辑:2
添加月份就可以了。
现在我只有这个:
insert into my_table
select f1, add_months( f2, 1 ) from my_table where status = etc etc
感谢您的帮助。
【问题讨论】:
标签: sql oracle function date math