- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 04:42 AM - edited 01-08-2024 10:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 11:54 PM
Hello @Community Alums
Why you have deleted your query and after accepting my solution why you have removed that, Can you please explain.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 04:53 AM
Hi,
Use below script
var date= new GlideDateTime(source.u_last_contact);
date = date.getByFormat('yyyy-mm-dd HH:mm:ss');
Regards,
Piyush Sain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 04:58 AM
Hi @piyushsain , How to handle two different format which are coming from source?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 10:37 PM
Hi @Community Alums
Whatever may be the source format if you use above code it will change the format to the required format
Regards,
Piyush Sain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 05:03 AM
Hello @Community Alums
Use this -
answer = (function transformEntry(source) {
var gdt = new GlideDateTime();
var parsedDate = new Date(source.u_last_contact);
if (!isNaN(parsedDate.getTime())) {
// Format the date as 'yyyy-MM-dd HH:mm:ss'
var formattedDate = parsedDate.toISOString().replace(/T/, ' ').replace(/\..+/, '');
return formattedDate;
}
else{
return source.u_last_contact;
}
})(source);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.