Hi Jeff,
Have you been able to get this working? If not, here is what works for me:
- In my OnSwitchView event, I have the following:
if(XDocument.View.Name == "View 1")
{
var objMyDate = XDocument.DOM.selectSingleNode("//my:myDate");
var objSunday = XDocument.DOM.selectSingleNode("//my:mySunday");
if(objMyDate.getAttribute("xsi:nil"))
objMyDate.removeAttribute("xsi:nil");
objMyDate.text = "2005-08-22";
if(objSunday.getAttribute("xsi:nil"))
objSunday.removeAttribute("xsi:nil");
//Call the date calc function and concatenate the pieces together for
use in JScript date calculations
objSunday.text = lastSunday(objMyDate.text.substr(5,2) + '/' +
objMyDate.text.substr(8,2) + '/' + objMyDate.text.substr(0,4));
}
Then I have this stand-alone function that is called from the above code
(this is modified from the web site I sent to you
function lastSunday(dtDate)
{
startDate = new Date(dtDate);
if(startDate.getDay() == 0)
{
// It's Sunday today, just subtract one week.
startDate.setDate( startDate.getDate() - 7);
}
else
{
// Walk backwards a day at a time until we get to Sunday.
while(startDate.getDay() != 0){
startDate.setDate( startDate.getDate() - 1);
}
}
var myYear = startDate.getYear();
var myMonth = startDate.getMonth() + 1;
if(myMonth < 10)
myMonth = "0" + myMonth;
var myDay = startDate.getDate();
if(myDay < 10)
myDay = "0" + myDay;
startDate = myYear + '-' + myMonth + '-' + myDay;
return startDate;
}
I hope this helps!
Scott L. Heim
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.