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;