Calculate end date from start date and number days to add
I'm trying to calculate a end date from a start date and number of days to add, both collected via user input. I've read the tutorials relevant and thought I understood how it worked but I can not figure out why my code wont output.
So user enters that the start date is 01/02/03 and it takes 5 days. I need the end date to output 01/07/03. I can't seem to see why it won't.
Here's what I've got:
-------------------------------------------------------------------------------------------------------------------
var startDate = this.getField("startDate_1").value; // get start date string
var endDate = this.getField("endDate_1"); // define the field the end date will be in
if(startDate.value != ""){
var dateConverted = util.scand("mm/dd/yy", startDate); // convert string to date object
var addDays = this.getField("days_1");
var oneDay = 24 * 60 * 60 * 1000;
var addDayMillis = addDays * oneDay;
var endMillis = dateStart.getTime() + addDayMillis;
var calcEndDate = new Date(endMillis);
endDate.value = util.printd("mm d, yy",calcEndDate);
}
else{
endDate.value = "----";
}
-------------------------------------------------------------------------------------------------------------------
What did I miss here?
