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!