I am using a rule from this site to convert 13-Oct-15 dates to October 13, 2015. It is working correctly, but when there is no data in the "GIFT_DATE" field I get this error "uncaught exception: Error in function "DateFromString": Could not convert "" to a valid date."
Is there something I can add to the rule so that I don't get the error for the empty "GIFT_DATE" fields. It makes it harder to catch real errors. The rule is below:
var str = Field("GIFT_DATE");
var MonthNameAbbrs = [ "jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec" ];
var month_name_part = 0;
var parts = str.replace(/-/g,'/').split('/');
for (var i = 0; !month_name_part && i < parts.length; i++)
{
if (isNaN(parseInt(parts)))
{
for (var m = 0; m < MonthNameAbbrs.length; m++)
{
if (ToLower(parts).substr(0,3) == MonthNameAbbrs[m])
{
parts = m + 1;
month_name_part = i + i;
break;
}
}
}
}
if (month_name_part)
{
var mpart = month_name_part - 1;
var mval = parts[mpart];
parts.splice(mpart, 1);
parts.splice(0, 0, mval);
}
var date = DateFromString(parts.join('/'));
return FormatDate(date, "lm d, yyyy");