Oracle calculates the number of days of a month based on the date

Source: Internet
Author: User

I haven't written anything for a while. I think of a function that I wrote to return the number of days when I used the number of days in a certain month in the Oracle query statement.ArticleNow, we have a little time to take it out for your use, and it is also convenient for your future needs.

Code

1 Create   Or   Replace   Function Get_month_days (select_month In   Varchar2 )
2 Return   Number   Is
3
4 Num_of_days Number ( 2 ); -- Number of days returned
5
6 Begin
7
8 /*
9
10 Name
11 Get_month_days
12 Description
13 Returns the total number of days of the month.
14 Arguments
15 V_select_month -- input month, in the format of yyyymm
16
17 */
18
19 Num_of_days: = Add_months (to_date (select_month, ' Yyyymm ' ), 1 ) - To_date (select_month, ' Yyyymm ' );
20
21 Return (Num_of_days );
22
23 End ;

 

 

 

If you have other good methods, share them with us ~

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.