Skip to Content

Issue with Dates conversion after deploying app to the SCP

Hello experts,

I have the next problem. I use odata version 2 for my fiori app. One of the entities contains property with type Edm.DateTime. For filtering data by date i use the next syntax:

oDate = new Date()
<...>
new sap.m.List(sId, {
<...>
filters: [new Filter("DateOfWork", "EQ", oDate)]
}
});

for format output i use formatter function as ussally:

dateFormat: function(oValue) {
//date: dd.mm.yyyy
var day = oValue.getDate();
var month = oValue.getMonth(); 
}

In WEB ide it works fine, when i deploy to abap repository it works fine as well, BUT when i deploy it to cloud platform it doesn't work. at first i get en error, because date is not converted to format required by http request for date, so it is passed just like a string and of course it doesn't work.

Then in formatter, oValue in not of js type Date (like in web ide), but string like "/Date(1404860400000)/"

I thought that probably issue is in models, but model looks the same. Do you have any idea? what can be a reason?


Best Regards,

Mikhail

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 17 at 09:01 PM

    Hey Mihail,

    The format you specified Date(1404860400000) is a milliseconds format of data object.

    The value can be accessed by following code

    var a = new Date(1404860400000);

    or in your case

    dateFormat:function(oValue){//date: dd.mm.yyyy
    
    var newDate = new Date(oValue);
    var day = newDate.getDate();
    var month = newDate.getMonth();}

    you could use this way of accessing inside your dateFormat formatter. Hope this helps.


    Regards,

    Karthik.


    Add comment
    10|10000 characters needed characters exceeded