Date in Requested Ite is coming in as in invalid formatted date when set in a run script in the workflow


Date Field has an invalid date of 04-01-0170 

Field is of Type "Date" in the Form



The script is using 

current.u_date = gs.daysAgo(-365); or this happens if you use any other API that returns a Date Time Value and setting it to a Date Field

daysAgo(Number days) 
Returns a date and time for a certain number of days ago. 
String The GMT in the format yyyy-mm-dd hh:mm:ss. ///returned format 

u_date is Date Type and you are setting a DateTime type directly so time component is getting converted to a weird date and should not be assigned directly without parsing


var gdt = new GlideDateTime(gs.daysAgo(-365)); 
current.u_date = gdt.getDate();

Using getDate() API along with dayAgo will render the Date properly