Transform algorithm in MySQL

hi all.

how to transform this algorithm in MySQL ? :

  • Start1 (from 2011/01/01 to 2011/02/20) = 10284 + (9749*20/28)=17247,6
  • Start2 (from 2011/01/01 to 2011/02/20) = 7045 + (7475*20/28)=12384,3

would be a progressive calculation today reported on previous year.

when 20 value is today previous year, 28 value is number of days the month February and remaining data are recorded in this table:


Maximum	Minimum	Months	Years	ID
10284	7045	1	2011	01
9749	7475	2	2011	02
8749	7666	3	2011	03
4911	2336	4	2011	04
7496	5826	5	2011	05
8526	7789	6	2011	06
4157	3300	7	2011	07
10566	9425	8	2011	08
23065	21333	9	2011	09
78965	56922	10	2011	10
3579	2000	11	2011	11
15963	11106	12	2011	12

hope for your help.

I have problem with extract the Maximum and Minimum for month 1 and 2.

This is my sql:

SELECT 
    Maximum
   ,Minimum
FROM doTable
WHERE 1
AND (Months=MONTH(CURRENT_DATE()) 
OR   Months=MONTH(ADDDATE(CURRENT_DATE(),INTERVAL - 1 MONTH))
AND  Years=YEAR(ADDDATE(CURRENT_DATE(),INTERVAL - 1 YEAR)));

the output for Maximum and Minimum is values of month 1, I need also Maximum and Minimum values of month 2…

Start1 (from 2011/01/01 to 2011/02/21):
Maximum month 1 + (Maximum month 2*today/number of days the current month)=17247,6

I need:

  1. Maximum month 2 value;
  2. today (only day);
  3. number of days the current month

Hope to get an answer on this soon, thanks!