Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to convert Date Time field value to ISO format value

Sanjay34
Tera Contributor

I have written below script on the "sn_customerservice_case" table to convert date time field value to ISO format.

var updated = current.getDisplayValue('sys_updated_on');    
    var dt = updated.split(' ');    
    var f = dt[0].split('-');    
    var t = dt[1].split(':');    
    var event = new Date(f[0], f[1]-1, f[2], t[0], t[1], t[2]);    
    gs.log("sanjay event " + event);
    var isoDate = event.toISOString();

In the log it is giving the result as "sanjay event Invalid Date". Please help to provide the solution.

9 REPLIES 9

Hi,

I have followed the same steps and after following the same steps I am facing the issue. In the event variable step I am getting "invalid date" value in the logs. Help me on this issue, why I am gating invalid date in event variable step

 

Community Alums
Not applicable

Hi,

Code looks fine check if correct value & format is being populated in variable  "updated'.

 

Regards,

Akshay

Hi,

Till var "t", I am getting the values but for the var "event" only I am getting the value as Invalid date.

 

Regards,

Sanjay