Conversion of date/time format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 01:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 04:13 AM
Hi,
Please try below:
Navigate to Transform Maps:
- Go to "System Import Sets" > "Transform Maps."
Open the Transform Map:
- Open the Transform Map associated with your import set.
Edit the Date/Time Field Mapping:
- Find the mapping for the date/time field that you want to transform.
- In the "Field Map" section, locate the field you want to transform.
Add a Scripted Transform:
- If there isn't a scripted transform already, add one by clicking "New" in the "Field Map" section.
- Choose "Script" as the transform type.
Write the Script:
- Write a script to parse the incoming date/time value, convert it to the desired format, and adjust the time if it is PM. Below is an example script:
(function transformEntry(source, map, log, target /*undefined onStart*/ ) {
var dateStr = source.u_your_date_time_field; // Replace with the actual field name
if (dateStr) {
var dateObj = new GlideDateTime();
dateObj.setDisplayValue(dateStr);
// Check if it's PM and add 12 hours
if (dateObj.isPM()) {
dateObj.addDaysUTC(0);
dateObj.addHoursUTC(12);
}
// Format the date in the desired format
target.u_your_date_time_field = dateObj.getDisplayValue();
}
})(source, map, log, target);
Replace "u_your_date_time_field" with the actual field name you are working with.
Regards,
Shoheb