View Full Version : Populate variables with prior month's dates.

08-28-2006, 03:32 PM

I am looking for a simple function that will create variables containing the previous month’s dates.
The case scenario:

User selects a month (ACCTMM) and year (ACCTYY) from two dropdowns on an .asp page. I need the function to calculate/subtract from the selection and return three variables containing the three prior months. I plan on having the function run onSubmit.

If user selects 03 & 2006, I need
ACCTYY1 = 2006 & ACCTMM1 = 02
ACCTYY2 = 2006 & ACCTMM2 = 01
ACCTYY3 = 2005 & ACCTMM3 = 12

I am having a very difficult time figuring out how to create this so that it will take into account only 12 months and will go back to the correct year when a prior month variable needed is ’before’ January.

I am still a novice coder, thank you in advance for your help!


08-28-2006, 04:51 PM
what do u mean by :"containing the three prior months."?

08-28-2006, 08:20 PM
I'm looking to populate 6 hidden variables that I will be passing on to another page:

ACCTYY1, ACCTMM1 (one month before dropdown choices)
ACCTYY2, ACCTMM2 (two months before dropdown choices)
ACCTYY3, ACCTMM3 (three months before dropdown choices)

Drop down choices are:
ACCTYY (four digits, any year)
ACCTMM (two digits, 01 thru 12)

Thanks :)