I am using the following in a script:
var startDate = new Date("10/12/2012");
var endDate = new Date("10/18/2012");
I would like those dates to be dynamically created with startDate as last Monday and endDate as last Sunday. I have tried the following:
var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var startDate = new Date(curr.setDate(first)).format("m/dd/yyyy");
var endDate = new Date(curr.setDate(last)).format("m/dd/yyyy");
But for some reason this doesn't work - nothing is outputted for the startDate or endDate variables.
Any ideas what I am doing wrong?