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