SELECT ADD_MONTHS(to_date('2008-06-30','yyyy-mm-dd'),-1) FROM dual;
本来按道理出来 的应该是2008-05-30怎么出来的是2008-05-31,
想出来上个月的今天,例如2008-06-25 出来应该是2008-05-25
本来按道理出来 的应该是2008-05-30怎么出来的是2008-05-31,
想出来上个月的今天,例如2008-06-25 出来应该是2008-05-25
解决方案 »
- 帮我看看错在哪里?
- 关于oracle中通过时间查询内容的问题
- 请帮我把这个子语句里面的TS字段 拿出来(因为外面有group by)
- update 语句问题
- 求大神看看 orcal客户端问题
- 关于oracle8i/9i安装问题,请教!!在线等待!!!!
- 简单问题,什么是触发器?它的机制是什么?作用是什么?有哪些类型没?
- proc中游标使用疑惑?
- 想模拟ORA-00316错误。
- ORA-12514: TNS:listener does not currently know of service requested in connect
- 如何通过NAT访问oracle?
- 数据库中的字符串能赋值给类中的date类型吗?
里一个重要概念
如果基准日是一个月的最后天,那计算后的日期也是该月的最后天
SELECT ADD_MONTHS(to_date('2008-02-29','yyyy-mm-dd'),1) FROM dual
求今年2.29加一个月,答案是3.31
SELECT ADD_MONTHS(to_date('2008-02-28','yyyy-mm-dd'),1) FROM dual
答案是3.28
Purpose
ADD_MONTHS returns the date d plus n months. The argument n can be any integer. If d is the last day of the month or if the resulting month has fewer days than the day component of d, then the result is the last day of the resulting month. Otherwise, the result has the same day component as d.