Skip to Content
0
Oct 30, 2017 at 01:00 PM

Convert Date Field in an Object Array of XSJS

647 Views

Dear All,

I am using below code in my xsjs to read data from Hana View. In the ResultSet Object,

a) In records Resultset object, I have all date fields coming in with value as 2017-10-12T00:00:00:000Z.

b) And few garbage values.

How can I modify the date object to represent just dd-mm-yyyy and get rid of absurd entries please ?

XSJS Code currently :

var conn = $.hdb.getConnection();
str = "SELECT *  FROM  WHERE \"COMPANY_CD\"=? AND \"DOC_KEY\" =? AND \"SYSTEM_ID\"=? AND \"POSTING_DATE\" BETWEEN ? AND ?"; 
records = conn.executeQuery(str, company, key, applnid, startdate, enddate);

I tried doing the below in a loop to select Date field in records Object and manipulating it. But it gave me a Type Error that the Date field is Read-Only.

records[i].INVOICE_DATE = (records[i].INVOICE_DATE.toString()).split('T')[0];

Can you please help on how can I modify records JSON with right values (and also by avoiding garage values like (-000001-12-31T00:00:00.000Z) please ?