接上贴oracle日期时间函数大全 日期和字符转换函数用法(to_date,to_char)select to_char(sysdate,'yyyy-mm-dd hh34:mi
接上贴oracle日期时间函数大全
日期和字符转换函数用法(to_date,to_char)
select to_char(sysdate,'yyyy-mm-dd hh34:mi:ss') as nowTime from dual; //日期转化为字符串
select to_char(sysdate,'yyyy') as nowYear from dual; //获取时间的年
select to_char(sysdate,'mm') as nowMonth from dual; //获取时间的月
select to_char(sysdate,'dd') as nowDay from dual; //获取时间的日
select to_char(sysdate,'hh34') as nowHour from dual; //获取时间的时
select to_char(sysdate,'mi') as nowMinute from dual; //获取时间的分
select to_char(sysdate,'ss') as nowSecond from dual; //获取时间的秒
求某天是星期几
sql> select to_char(to_date('2015-10-27','yyyy-mm-dd'),'day') from dual;
TO_CHA
------
星期二
两个日期间的天数
SQL> select floor(sysdate - to_date('20020405','yyyymmdd')) from dual;
FLOOR(SYSDATE-TO_DATE('20020405','YYYYMMDD'))
---------------------------------------------
4949
年月日的处理
select older_date,
newer_date,
years,
months,
abs(
trunc(
newer_date-
add_months( older_date,years*12+months )
)
) days from ( select
trunc(months_between( newer_date, older_date )/12) YEARS,
mod(trunc(months_between( newer_date, older_date )),12 ) MONTHS,
newer_date,
older_date
from (
select hiredate older_date, add_months(hiredate,rownum)+rownum newer_date
from emp
)
)
处理月份天数不定的办法
select to_char(add_months(last_day(sysdate) +1, -2), 'yyyymmdd'),last_day(sysdate) from dual
原文地址;Http://plat.delit.cn/thread-183-1-1.html
转载请注明出处;
撰写人:度量科技http://www.delit.cn
--结束END--
本文标题: oracle日期函数部分用法
本文链接: https://lsjlt.com/news/41570.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0