B
Bobby
I am using the following script to calculate a new date in InfoPath 2003,
however, the output date format is in yyyy-mm-dd instead of the mm/dd/yyyy I
started with and need it to be. Changing the properties of the output field
to anything but "text(string)" prevents the script from running. What am I
doing wrong? How do I change the dateObj format back from yyyy-mm-dd?
Thanks.
function GetDateString(dateObj)
{
var yyyy = dateObj.getFullYear();
var mm = dateObj.getMonth() + 1;
var dd = dateObj.getDate();
if (mm < 10)
mm = "0" + mm;
if (dd < 10)
dd = "0" + dd;
return yyyy + "-" + mm + "-" + dd;
}
function msoxd_my_ReferralDate::OnAfterChange(eventObj)
{
if (eventObj.IsUndoRedo)
return;
var dateObj = new
Date(eventObj.Site.text.replace(/(\d\d\d\d)-(\d\d)-(\d\d)/, "$2-$3-$1"));
var dateVal = dateObj.getDate();
dateObj.setDate(dateVal + 45);
XDocument.DOM.selectSingleNode("my:IFSP/my:FourtyFifthDay").text =
GetDateString(dateObj);
}
however, the output date format is in yyyy-mm-dd instead of the mm/dd/yyyy I
started with and need it to be. Changing the properties of the output field
to anything but "text(string)" prevents the script from running. What am I
doing wrong? How do I change the dateObj format back from yyyy-mm-dd?
Thanks.
function GetDateString(dateObj)
{
var yyyy = dateObj.getFullYear();
var mm = dateObj.getMonth() + 1;
var dd = dateObj.getDate();
if (mm < 10)
mm = "0" + mm;
if (dd < 10)
dd = "0" + dd;
return yyyy + "-" + mm + "-" + dd;
}
function msoxd_my_ReferralDate::OnAfterChange(eventObj)
{
if (eventObj.IsUndoRedo)
return;
var dateObj = new
Date(eventObj.Site.text.replace(/(\d\d\d\d)-(\d\d)-(\d\d)/, "$2-$3-$1"));
var dateVal = dateObj.getDate();
dateObj.setDate(dateVal + 45);
XDocument.DOM.selectSingleNode("my:IFSP/my:FourtyFifthDay").text =
GetDateString(dateObj);
}