Oracle Queries month and month

Source: Internet
Author: User

When you need to use these 2 times, first of all, simply:

If you order the monthly product of March 15, the end of the month, then you should charge a 17-day fee, this time should determine whether the order time is greater than the beginning of the month time.
If you only use the March 25, then you should charge 11 days, this time you need to determine whether the use of time is less than the end of time. and the order time and the time of use
is generally present in the product table. The monthly pricing plan exists in the pricing table, so it is said that the cost of approving the user is to use the month end, the beginning of time.

Find the month of the month
Select to_date (To_char (sysdate, ' yyyy-mm ') | |
'-01 00:00:01 ',
' Yyyy-mm-dd HH24:MI:SS ')
Into Month_begin_time
From DUAL;

Find the end of this month
Select to_date (To_char last_day (sysdate),
' Yyyy-mm-dd ') | | ' 23:59:59 ',
' Yyyy-mm-dd HH24:MI:SS ')
Into Month_end_time
From DUAL;

Find early last month
Select to_date (To_char (Add_months (sysdate,-1), ' yyyy-mm ') | |
'-01 00:00:01 ',
' Yyyy-mm-dd HH24:MI:SS ')
Into Last_month_begin_time
From DUAL;

//Find the month end of last month
Select to_date (To_char last_day (add_months sysdate,-1),
                               ' yyyy-mm-dd ') | | ' 23:59:59 ',
                              ' Yyyy-mm-dd HH24:MI:SS ')
          into Last_month_end_time
           from DUAL;

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.