Date/Time format is changing will importing through Transform Map

Anubhav Ritolia
Kilo Contributor

Hi All,

When I am trying to import value for Date/Time field, and it the hours is 12, it is automatically converting it to 00. But it is working properly when it is 13Hr or even 23Hr.

For example, If I import 2020-03-05 12:50:40 in system it comes as 2020-03-05 00:50:40.

But, If I import 2020-03-05 13:50:40 in system it comes as 2020-03-05 13:50:40 properly. 

Also there is no AM or PM mentioned. What can be the issues?

This is happening for all Date/Time fields present in my table.

 

1 ACCEPTED SOLUTION

AnubhavRitolia
Mega Sage
Mega Sage

Hi All,

 

Issue was solve just by changing the Date/Time Format in Field mapping from yyyy-mm-dd hh:mm:ss to yyyy-mm-dd HH:mm:ss.

 

Just changed hh to HH format.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

View solution in original post

11 REPLIES 11

Hi,

Can you share how it looks in import set table since you are doing some split etc?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

They are sending date as 2020-04-03 12:25:35.344.

So we are just splitting to remove that milli-second part. And as the field in Tmport set table is string, it is same as 2020-04-03 12:25:35.344.

Hi Anubhav,

did you check by adding log whether you are getting the correct value after doing the split etc

Did you check for which values it is behaving in this way

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Can you use onBefore transform script instead of field map and use this script


// your string manipulation here
// then do this

var time = new GlideDateTime(datTime);
target.<fieldName> = time;

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

this worked for me well in onBefore transform script

target.setDisplayValue('u_sample_date_time', source.u_time_string);

Incoming value: 2020-04-03 12:25:35

Target Value: Set correctly

So you also try to handle using onBefore transform script; Also ensure the source field is of type string and not date/time

find_real_file.png

find_real_file.png

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader