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

@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

Hi @Ankur Bawiskar 
Thank you for your quick reply on this.
It worked like a magic!! 😀

OmkarJori_0-1691127914283.png

 

Glad to help.

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