I needed to work out a date range according to the date 3weeks away from the current date.
After a bit of thinking, I found that it’s actually quite easy to achieve.
var theDate:Date = new Date();
dateDay = theDate.getDate();
dateMonth = theDate.getMonth();
dateYear = theDate.getFullYear();
var theDate2:Date = new Date(dateYear,dateMonth,dateDay);
theDate2.setDate(theDate2.getDate() + 21);
dateDay2 = theDate2.getDate();
dateMonth2 = theDate2.getMonth();
dateYear2 = theDate2.getFullYear();
The above code gets the current date and adds 21days/3weeks to it.
Remember that if you use getMonth to output the final month number, you will want to add 1 to it as it starts at 0;
Example:dateMonth2 = theDate2.getMonth()+1;
So you would do it like this:theDate2.getDate() +"/"+ (theDate2.getMonth()+1) +"/"+ theDate2.getFullYear();