Hi,
I have a table which containt a date, a number for the number of weeks per period, and a year. the user then enters a date and I can calculate the period number from this. But I'd like to do it the other way too: Entering a period number and get the start and end date of the period from this. Unfortunately, I can't seem to get the right logic. Could anyone guide me with this?
Thank you.
EDIT: options[0] being the start date from the database and options[1] the number of weeks for one period.
This is the function I already have and which works:
private function dateToPeriod(date:Date):Number
{
var d = new Date(options[0]);
var periode = Math.floor((date.time - d.time)/(604800000*options[1])+1);
return periode;
}
let's say my start date it 12/12/2009, then passing 12/12/2009 to this function would return 1 since it's the first "period" from this date (in week number).
What I want is to make a periodToDate function.