首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

oracle 惯用日期函数

2012-07-04 
oracle 常用日期函数?D???一周中的星期几DD???月中的第几天Select to_char(sysdate,DD) As 返回本月第几

oracle 常用日期函数
?D???一周中的星期几DD???月中的第几天Select to_char(sysdate,'DD') As 返回本月第几天 from dualDDD???年中的第几天Select to_char(sysdate,'DDD') As 返回本年第几天 from dualDAY????星期的名字Select to_char(sysdate,'DAY') As 返回星期 from dualDY???星期的简写名Select to_char(sysdate,'DY') As 返回星期 from dualYYYY??四位年份Select to_char(sysdate,'YYYY') As "四位的年份【2012年】" from dualYYY,YY,Y???年份的最后三位,两位,一位Select to_char(sysdate,'YYY') As "三位的年份【2012年】" from dualHH?? 小时,按12小时计Select to_char(sysdate,'HH') As "12小时制" from dualHH24?小时,按24小时计Select to_char(sysdate,'HH24') As "24小时制" from dualMI??分Select to_char(sysdate,'MI') As 返回分 from dualSS??秒Select to_char(sysdate,'SS') As 返回当前秒 from dualMM??月Select to_char(sysdate,'MM') As 返回当前月份 from dualMon??月份的简写Select to_char(sysdate,'Mon') As 返回当前月份 from dualMonth???月份的全名Select to_char(sysdate,'Month') As 返回当前月份 from dualW???该月的第几个星期Select to_char(sysdate,'W') As 本月第几周 from dualWW?? 年中的第几个星期?Select to_char(sysdate,'WW') As 本年的第几周 from dualQ年中的季度Select to_char(sysdate,'Q') As 返回本年的季度 from dual???? 常用日期操作语句1返回上个月最后一天Select to_char(add_months(last_day(sysdate),-1),'yyyy-MM-dd') 返回上个月最后一天 from dual;2返回上个月第一天Select to_char(add_months(last_day(sysdate)+1,-2),'yyyy-MM-dd') 返回上个月第一天 from dual;??3返回上个月的今天Select to_char(add_months(sysdate,-1),'yyyy-MM-dd') 上个月的今天 from dual;4返回当前月第几周Select to_char(sysdate,'WW') 返回本月第几周 from dual group by to_char(sysdate,'WW');5返回本年第几月Select to_char(sysdate,'MM') 返回本年第几月 from dual group by to_char(sysdate,'MM');6返回本年第几季Select to_char(sysdate,'Q') 返回本年第几季 from dual group by to_char(sysdate,'Q');7返回当前月份星期
为周日的日期Select to_char(t.d, 'YY-MM-DD') 返回当前月份星期为周日的日期
? from (select trunc(sysdate, 'MM') + rownum - 1 as d
????????? from dba_objects
???????? where rownum < 32) t
?where to_char(t.d, 'MM') = to_char(sysdate, 'MM') --找出当前月份的周五的日期
?? and trim(to_char(t.d, 'Day')) = '星期日'

热点排行