oracle日期函数、字符串函数 格式化方式

select last_day(sysdate) from dual;--当前日期对应月份的最后一天

select next_day(sysdate,'星期二') from dual;--某个时间对应星期的下一周期

select add_months(sysdate,2) from dual;--某个时间对应月份的下几个月份
select ename,trunc(months_between(sysdate,hiredate)) from emp;--员工入职至现在共计多少个月 ; emp为测试表
select to_char(sysdate,'yyyy-mm-dd') time from dual;--日期格式化为'yyyy-mm-dd'格式进行展示
select to_char(sysdate,'yyyy') year ,to_char(sysdate,'mm') month,to_char(sysdate,'dd')from dual;--查询某个日期所对应年、月、日、时。分、秒
select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') time from dual;--某个日期以XX格式显示(12小时:时分秒)
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') time from dual;--某个日期以XX格式显示(24小时:时分秒)
select to_char(890783453485,'999,999,999,999,999,999') from dual;--以某格式显示传入参数 select to_char(890783453485,'L999,999,999,999,999,999') from dual;--(L代表当前语言环境下的货币符号)
select to_date('1989-06-24','yyyy-mm-dd') from dual;--格式化时间
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';--更改当前会话的日期显示方式

 

posted @ 2018-09-20 14:10  时间与灵药  阅读(11152)  评论(0)    收藏  举报