Date format issue while transforming data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 08:26 AM
Hello Developers,
Hope everyone is doing great!
While loading data using import sets/ transform map date format is getting changed.
The source instance date format is: MM-dd-YY HH:MM:SS
The target instance date format is: YY-MM-dd HH:MM:SS
While loading data in the staging table in target MM-dd values are getting swapped.
for example :
Created field in source: 06-11-2020
Created field in stating table after loading data changes to 2020-11-06 (MM got swapped with DD)
Requesting your kind assistance to help me solve this problem.
I am debugging this and can't figure out a solution.
Thanks,
AbdulRahim Shaikh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 08:39 AM
in transform mapping update target date format in list view not form.
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 08:45 AM
Hey Bharath,
Thanks for your response I will give this a try.
I also have the script for system fields on how to set date format for them.
Below is the code :
target.autoSysFields(false);
// system fields
var gdtc = new GlideDateTime(source.u_created);
target.sys_created_on = gdtc.getValue();
target.sys_created_by = source.u_created_by;
var gdtu = new GlideDateTime(source.u_updated);
target.sys_updated_on = gdtu.getValue();
target.sys_updated_by = source.u_updated_by;
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 08:57 AM
var gdtc = new GlideDateTime(source.u_created);
target.sys_created_on = gdtc.getByFormat("YY-MM-dd HH:MM:SS");
target.sys_created_by = source.u_created_by;
var gdtu = new GlideDateTime(source.u_updated);
target.sys_updated_on = gdtu.getByFormat("YY-MM-dd HH:MM:SS");
target.sys_updated_by = source.u_updated_by;
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 08:40 AM - edited 02-12-2023 08:44 AM
Hello @AbdulRahim Shai ,
You can try using source script for this and add below two lines in the script:
var sourceDate = new GlideDateTime(source.date_field); //add source field name
return sourceDate.getValue();
The another option is you can try setting the source date format in the Date Format field, like in your case it will be MM-dd-yyyy HH:mm:ss
If my answer has helped with your question, please mark it as helpful and give it a thumbs up!
Regards,
Shubham