Webservice json response to date

Posted by Jorrit on 25-May-2016 10:03

Hi,

Im working on a serverside webservice call rest/json. In the response i get a date with format dd/MM/yyyy.

example:

"datum_eerste_afgifte_nederland":"31/12/2013","datum_eerste_toelating":"31/12/2013","datum_tenaamstelling":"31/12/2013"

When i want to put the date in a variable and use rbv_api.setFieldValue or rbv_api.updateRecord i get the error "not a date".

Here is a snippet of the code:

var v_date1 = new Date();
var v_tenaam = new Date();
var v_afgnl = new Date();

//loop trough result
var i;
for(i = 0; i < v_arr.length; i++) {

v_date1 = v_arr[i].datum_eerste_toelating;
v_date1 = rbv_api.formatDate(v_date1, "dd/MM/yyyy");
}

rbv_api.println(v_date1);

rbv_api.setFieldValue("vehicle1", {!id}, "vehicle1d_firstadmission", v_date1);

How to set te value v_date1 to a correct format to update a record?

Regards Jorrit

All Replies

Posted by Jorrit on 26-May-2016 02:55

Hi,

I managed to write a function to set the date to string:

function format_date(v_data){

 var v_day = v_data.substring(0, 2);

 var v_mon = v_data.substring(3, 5) - 1;

 var v_yea = v_data.substring(6, 10);

 var v_date = new Date(v_yea,v_mon,v_day);

 return v_date;

}

its working.

Regards Jorrit

This thread is closed