Home > Database > Mysql Tutorial > oracle中从指定日期中获取月份或者部分数据

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

WBOY
Release: 2016-06-07 16:22:47
Original
1458 people have browsed it

从指定日期中获取部分数据: 如月份: 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;

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template