Date format issue after importing from REST Integration (GET Method)

Omkar Jori
Tera Expert

Hi all,
I am facing a issue while importing the Date/Time field from Source instance.
Source Instance (display_value) -
Record 1 - 02-08-2023 10:46:14

Record 2 - 13-12-2022 19:45:06


Target Instance :
Record 1 - 2023-02-08 10:46:14 

OmkarJori_2-1691116562689.png

 

 

Record 2 - 2022-12-13 19:45:06 (Expected format)

OmkarJori_1-1691116508034.png


Even the Source field format is same for both the records still value is reflecting differently in Same Field.


Value imported using display_value method: 

OmkarJori_0-1691116458519.png

The data should be imported in 2nd Record Format.
Please let know the possible way to resolve this.

 

1 ACCEPTED SOLUTION

@Omkar Jori 

something like this. I assume the source value always has this format  dd-MM-yyyy HH:mm:ss

var dateTime = parsedData.result[i].sys_updated_on.display_value;
		var gdt = new GlideDateTime();
		var simpleDateFormat = 'dd-MM-yyyy HH:mm:ss';
		gdt.setDisplayValue(dateTime, simpleDateFormat);
		gr.setValue('u_source_updated_on',gdt.getValue());

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

View solution in original post

7 REPLIES 7

Anil Lande
Kilo Patron

Hi,

Can you please share what configurations you have done at Transform map field mapping?

What is the Date format in your Payload (I hope it is fixed).

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi @Anil Lande 
Payload showing this values, which I mentioned below 
Source Instance (display_value) -
Record 1 - 02-08-2023 10:46:14

and the code is written in schedule job.

Ankur Bawiskar
Tera Patron
Tera Patron

@Omkar Jori 

you need to convert the source value to the format of YYYY-MM-dd HH:mm:ss

OR

can you try with just this? don't use display_value from json

gr.u_source_updated_on = parsedData.result[i].sys_updated_on;

Could you also share the json body how it looks like?

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

Hi @Ankur Bawiskar 
Could you share the method to convert the date format to YYYY-MM-dd HH:mm:ss, of parsedData.result[i].sys_updated_on;