Jump to content

European Date Compose Error


Susan

Recommended Posts

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");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...