Oracle ADD_MONTHS 使用
来源:互联网 发布:oracl创建数据库 编辑:程序博客网 时间:2024/04/27 04:22
需要脚本,自动清空分区数据。表是按月分区,希望每月自动执行一次,清空下个月的分区数据。
分区后缀是两位数月份,不足前面补0。
SQL> select lpad(extract(month from(add_months(to_date('2012-12-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss'), 1))), 2, '0') aa from dual;
AA
--
01
SQL> select lpad(extract(month from(add_months(to_date('2012-11-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss'), 1))), 2, '0') aa from dual;
AA
--
12
SQL>
标准文档:
ADD_MONTHS
Syntax
Description of the illustration add_months.gif
Purpose
ADD_MONTHS
returns the date date
plusinteger
months. The date argument can be a datetime value or any value that can be implicitly converted toDATE
. The integer
argument can be an integer or any value that can be implicitly converted to an integer. The return type is alwaysDATE
, regardless of the datatype of date
. Ifdate
is the last day of the month or if the resulting month has fewer days than the day component ofdate
, then the result is the last day of the resulting month. Otherwise, the result has the same day component asdate
.
See Also:
Table 2-10, "Implicit Type Conversion Matrix" for more information on implicit conversionExamples
The following example returns the month after the hire_date
in the sample tableemployees
:
SELECT TO_CHAR( ADD_MONTHS(hire_date,1), 'DD-MON-YYYY') "Next month" FROM employees WHERE last_name = 'Baer';Next Month-----------07-JUL-1994
- Oracle ADD_MONTHS 使用
- oracle中add_months(增加或减去月份 )使用
- ORACLE 日期函数 ADD_MONTHS
- ADD_MONTHS的用法-Oracle
- ADD_MONTHS(oracle)特例
- ORACLE日期函数ADD_MONTHS
- ORACLE 日期函数 ADD_MONTHS
- ORACLE 日期函数 ADD_MONTHS
- oracle中的add_months()函数
- ADD_MONTHS函数 的使用
- Oracle months_between()和add_months()函数
- oracle中的add_months()函数总结
- oracle add_months函数的用法
- ADD_MONTHS
- ADD_MONTHS
- oracle中add_months和trunc用法
- Oracle中add_months()函数的用法
- oracle中add_months和trunc用法
- MTK history机制
- UINavigationController的出栈和入栈
- 关于mysql启动时的Starting MySQL..Manager of pid-file quit without updating提示
- 在 android移植FFT 傅里叶变换库
- POJ 1679 The Unique MST
- Oracle ADD_MONTHS 使用
- Little定律
- PHP调用DLL
- 英语练习137 If I were millionaire
- 正则表达式语法
- View HTTP Request/Response Headers in Browser
- java创建XML文件
- HTTP封装类 工具类 For Android
- 结构体里字符数组异常