- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2021 12:20 PM
How to convert string field value to date field using transform map
string field value : 01-APR-1967 (u_actual_date)-->string field
date field format : MM-dd-yyyy (actual_start)--> date field
below code not working:
OnBefore
if (!source.u_actual_date.nil()) {
var sec = Date.parse(source.u_actual_date);
var gdt = new GlideDateTime();
gdt.setNumericValue(sec);
target.actual_start = gdt.getDisplayValue();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2021 08:08 AM
I have found the solution by modifying the transform map script
On before
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var gd = new GlideDate();
gd.setDisplayValue(source.u_actual_date, "dd-MMM-yyyy");
var dt = gd.getByFormat("MM-dd-yyyy");
target.actual_date= dt;
//gs.info("SUCCESSFUL : ", dt);
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2021 06:49 AM
Hello,
Glad you found a solution that worked for you. For any future readers, if you configure the source format correctly, you shouldn't need to build your own script to map. If your source data does not include time (such as HH:mm:ss, etc.), then in the source formatting, you wouldn't include time, just the date format as presented in your source data.
Take care!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!