当前位置:首页 > PHP教程 > PHP总结归纳

oracle中从指定日期中获取月份或者部分数据

从指定日期中获取部分数据: 如月份: select to_char(sysdate,'mm') from dual; 或者: select extract(month from sysdate) from dual; 又或者最笨的方法,用to_char()先把日期转化为指定格式的字符串,在通过substr()这个取到想要的数据。 select substr(

  从指定日期中获取部分数据:

  如月份:

  select to_char(sysdate,'mm') from dual;

  或者:

  select extract(month from sysdate) from dual;

  又或者最笨的方法,用to_char()先把日期转化为指定格式的字符串,,在通过substr()这个取到想要的数据。

  select substr(to_char(sysdate,'yyyy-mm-dd'),6,2) from dual;

  获取日期其它部分数据和上方法一样。

.syntaxhighlighter{padding-top:20px;padding-bottom:20px;}
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!