阅读更多
1、add_months()用于从一个日期值增加或减少一些月份
SQL> select add_months(sysdate,12) from table_name;
2、months_between()判断两个日期之间的月份数量
number_value:=months_between(date_value,date_value)
SQL> select months_between(sysdate,date'2010-05-18') from table_name;
3、sysdate oracle数据库当前日期
select to_char(sysdate-1,'yyyy-MM-dd') from table_name;
to_char(val1,val2)是将日期类型转成string类型
to_date(val1,val2)是将字符类型转成日期类型
4、
取整(向下取整):
select floor(5.534) from dual;
select trunc(5.534) from dual;
上面两种用法都可以对数字5.534向下取整,结果为5.
如果要向上取整,得到结果为6,则应该用ceil
select ceil(5.534) from dual;
四舍五入:
SELECT round(5.534) FROM table_name;
SELECT round(5.534,0) FROM table_name;
SELECT round(5.534,1) FROM table_name;
SELECT round(5.534,2) FROM table_name;
结果分别为 6, 6, 5.5, 5.53