The month of mysql queries the data of payment in that month

  • 2020-05-09 19:29:13
  • OfStack

ktime start time series
dtime expiration time series
jmonth monthly number of paid shares optional (1,3,6,12)
You need to query the data on a monthly basis
For example, ktime=1228406400(2008-12-5) dtime=1259856000(2009-12-4) jmonth=3
Starting from 2008-12-5, a 3-month interval will be charged until passage 12-5
The first time is passage 12-5
The second charge will be charged on 2009-2-28 (5 days in advance)
The third charge will be charged on 2009-5-31 (5 days in advance)
The fourth charge will be charged on 2009-8-31 (5 days in advance)
Now I need to check the data of February 2009 and I can check it out.
Check the March 2009 payables for the top example
May 2009 can also be found.



$stime="2009-05";  The current month , The selected query month.  
$stimes="200905"; 
$mintime=1241107200(2009-05-01 00:00:00); 
$maxtime=1243785600(2009-06-01 00:00:00);  in +1 
$sql="select * from t_list where del=0 and ( (ktime>={$mintime} and ktime<$maxtime) or (ktime<$mintime and dtime-5*24*60*60>$maxtime and PERIOD_DIFF(".$stimes.",DATE_FORMAT(FROM_UNIXTIME(ktime-5*24*60*60),\"%Y%m\")) mod jmonth=0) ) order by ktime desc"; 


(ktime > ={$mintime} and ktime < $maxtime) for the current month
ktime < $mintime and dtime-5*24*60*60 > $maxtime except for the current month when it starts and the current month when it expires
PERIOD_DIFF(".$stimes.",DATE_FORMAT(FROM_UNIXTIME(ktime-5 *24*60*60),\"%Y%m\))) the number of months between the current month and the start time
mod jmonth=0 the number of shares remaining between the current month and the start time and the number of shares remaining between the paid months are required to pay for the current month.

Related articles: