- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 06:56 AM
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:
Please help how to resolve this. Thanks.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 01:15 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 08:38 AM
Looking at the numeric string it may be just the number of seconds to add. Do you have a start date field? If not, you can always use the current date/time and add that number of seconds:
answer = (function transformEntry(source) {
var dt = new GlideDateTime();
dt.addSeconds(20210526);
return dt;
})(source)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 12:20 PM
Thanks for your response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 01:15 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 01:50 PM
Adding on to the great answer by
Frank