Expand my Community achievements bar.

SOLVED

Changing the Date format from json Data

Avatar

Level 1
Level 1

Hi 

We are having JSON data having Transaction Date attribute but the values in format of 20250122160808(YYYYMMDDHHRRSS).

So i need to change to (for Eg 2025-01-22 16:10:58) YYYY-MM-DD HH:RR:SS This format.

How i can achieve this using JS code.


1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @VV7 ,

You can try the below,

vars.jsonTime= '20250122160808';
vars.DateFormat = vars.jsonTime.substr(0,4)+'/'+vars.jsonTime.substr(4,2)+'/'+vars.jsonTime.substr(6,2)+' '+vars.jsonTime.substr(8,2)+':'+vars.jsonTime.substr(10,2)+':'+vars.jsonTime.substr(12,2);
logInfo("jsonTime: "+vars.jsonTime);
logInfo("DateFormat: "+vars.DateFormat);

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @VV7 ,

You can try the below,

vars.jsonTime= '20250122160808';
vars.DateFormat = vars.jsonTime.substr(0,4)+'/'+vars.jsonTime.substr(4,2)+'/'+vars.jsonTime.substr(6,2)+' '+vars.jsonTime.substr(8,2)+':'+vars.jsonTime.substr(10,2)+':'+vars.jsonTime.substr(12,2);
logInfo("jsonTime: "+vars.jsonTime);
logInfo("DateFormat: "+vars.DateFormat);