In oracle, the month or part of data is obtained from the specified date. The oracle date

Source: Internet
Author: User

In oracle, the month or part of data is obtained from the specified date. The oracle date

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.




How does one obtain the year in the date in oracle?

Select to_char (field, 'yyyy') from table name;
For example:
Select to_char (accpttime, 'yyyy') from corinfo;

Example: how to obtain the month in the Date Field in SQL (under oracle)

Select to_char (date column, 'mm') as month from Table Name

Related Article

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.