in reply to Re^4: Dynamic SQL script
in thread Dynamic SQL script

Don't get me wrong, your code works great, but the dates are not correct. Let me see if I can explain it better. The second calculation needs to begin 1 year back + 1 month and march towards the current month for the # of months equal to # of days/30. For example, assuming the current month is 11/06 and # of days = 120, the beginning month would be 1 year back (11/05) + 1 month so it would be 12/05 and would sum months (12/05 + 01/06 + 02/06 + 03/06).
Here's how the table is setup: mth_00 = current month (11/2006) mth_01 = 10/2006 mth_02 = 09/2006 mth_03 = 08/2006 mth_04 = 07/2006 mth_05 = 06/2006 mth_06 = 05/2006 mth_07 = 04/2006 mth_08 = 03/2006 mth_09 = 02/2006 mth_10 = 01/2006 mth_11 = 12/2005 mth_12 = 11/2005 mth_13 = 10/2005 mth_14 = 09/2005 etc... Here's the date ranges for each of the months (assume # of days = 120) If current month = 11, month range should be 8,9,10,11 If current month = 10, month range should be 9,10,11,12 If current month = 09, month range should be 10,11,12,13 If current month = 08, month range should be 11,12,13,14 If current month = 07, month range should be 12,13,14,15 If current month = 06, month range should be 13,14,15,16 etc...

Replies are listed 'Best First'.
Re^6: Dynamic SQL script
by sasrs99 (Acolyte) on Nov 17, 2006 at 18:19 UTC
    If anyone can help me with this I'd greatly appreciate the help. I'm stuck!