Obtain month or part of data from a specified date in oracle

Source: Internet
Author: User
Obtain part of the data from the specified date, such as month: selectto_CHAR (sysdate, MM) FROMDUAL; or: selectextract (monthfromsysdate) fromdual; or the most stupid method, use to_char () first, convert the date to a string in the specified format and obtain the desired data through substr. Selectsubstr (

Obtain part of data FROM a specified date, such as month: select to_CHAR (sysdate, 'mm') from DUAL; or: select extract (month from sysdate) FROM dual; or the most stupid method, use to_char () to first convert the date to a string in the specified format, and get the desired data through substr. Select substr (

Obtain part of the data from the specified date:

Such as month:

Select to_CHAR (sysdate, 'mm') from dual;

Or:

Select extract (month from sysdate) from dual;

Or the most stupid method, use to_char () to first convert the date to a string in the specified format, and get the desired data through substr.

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

Obtain other data of the date in the same way as the previous method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.