修改日期格式为年月日时分秒: alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期转化为年月日时分秒格式
select to_char(sysdate,'yyyy') nowYear from dual; //获取时间的年
select to_char(sysdate,'mm') nowMonth from dual; //获取时间的月
select to_char(sysdate,'dd') nowDay from dual; //获取时间的日
select to_char(sysdate,'hh24') nowHour from dual; //获取时间的时
select to_char(sysdate,'mi') nowMinute from dual; //获取时间的分
select to_char(sysdate,'ss') nowSecond from dual; //获取时间的秒
前一个月日期: select add_months(trunc(sysdate),-1) from dual;
前一个月:select TRUNC(add_months(trunc(sysdate),-1),'MM') from dual;
后一个月转换为字符串:select to_char(add_months(trunc(sysdate),1),'yyyymm') from dual;
将字符串类型的日期,转为日期类型
SELECT to_char(to_date(m.CREATEDDATE,'yyyy-MM-dd hh24:mi:ss'),'yyyy-MM-dd') FROM dfform_xxsb m ;
排序取前10
select * from (select * from test order by statedate desc ) where rownum<=10;
参考链接:https://blog.csdn.net/seekandfindyou/article/details/80668980