Date format issue while transforming data

AbdulRahim Shai
Tera Expert

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

 

7 REPLIES 7

BharathChintala
Mega Sage

@AbdulRahim Shai 

in transform mapping update target date format in list view not form.

 

BharathChintala_0-1676219950008.png

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

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,






 

@AbdulRahim Shai 

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;

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

Shubham_Shinde
Giga Guru

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