Number of days in the month of the Oracle query date

Source: Internet
Author: User

The Oracle query date operation can implement many dates we need. For example, we can implement the number of days in the month to which the Oracle query date belongs. Let's take a look at the implementation of this method.

The number of days of the month to which the Oracle query date belongs:

Select to_char (last_day (to_date ('201312', 'yyyy-mm-dd'), 'dd') from dual is to query the date value of the day after the month, the parameter of the last_day function must be in 'yyyy-mm-dd' format.

Query the number of days of the month in the previous month or the number of months in the previous month.

Add_months 'yyyy-mm-dd', count) is the date corresponding to this date plus count months

The system can automatically identify the number of days in the second month of the leap year and the second month:

Select to_char (last_day (to_date (to_char (add_months (to_date ('2013', 'yyyy-mm-dd'),-1), 'yyyymmdd '), 'yyyy-mm-dd'), 'dd') days from dual

For example:

Select to_char (add_months (to_date ('201312', 'yyyy-mm-dd'),-1), 'yyyymmdd') from dual

The result is 20080229.
 

The preceding describes how to query the number of days in the month of an Oracle query date.

Learn more about Oracle hierarchical Query

Oracle statements used to query all tables of a user

Oracle with statement usage

Implementation of Oracle query of user tablespace

Oracle index Optimization Design

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.