Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Unable to format date in Transform Map

jxa7987
Tera Expert

I'm importing data from JDBC and getting date error:

"Unable to format 20,210,526 using format string yyyy-MM-dd for field due_by (Date Time field) "

In field map the date format I set:

 

 

find_real_file.png

Please help how to resolve this. Thanks.

1 ACCEPTED SOLUTION

That's different. In which case, I would eliminate the commas and format accordingly. Here is proof that you can run in Scripts - Background:

var oString = '20,210,526';
var nString = oString.replace(/,/g, "");
gs.info(nString);
var yyyy = nString.slice(0,4);
var mm = nString.slice(4,6);
var dd = nString.slice(6,8);

gs.info(yyyy);
gs.info(mm);
gs.info(dd);

var gd = new GlideDate();
gd.setDate(yyyy + '-' + mm + '-' + dd);
gs.info(gd);

View solution in original post

5 REPLIES 5

jxa7987
Tera Expert

Here's the exact script I used in transform map script.  Thanks for the help @ccajohnson 

 

var oString = source.duedate;	
var nString = oString.replace(/,/g,"");
var yyyy  = nString.slice(0,4);
var mm = nString.slice(4,6);
var dd = nString.slice(6,8);
	
var gd = new GlideDate();
gd.setValue(yyyy + '-' + mm + '-' + dd);
target.due_date = gd.getDisplayValue();