cancel
Showing results for 
Search instead for 
Did you mean: 

Date issue "Uncaught TypeError: d.getDay is not a function"

Former Member
0 Kudos

Hi All,

I am trying to modify date format in a dialogue that is being called from view. following is the code from view and controller.

toolbar: new sap.ui.commons.Toolbar({

                items: [

new sap.ui.commons.Button('edit_btn',{

                        text: "Edit Note",

                        icon: "sap-icon://edit",

                        enabled: false,

                        press: oController.editNotePress.bind(oController)

                    }),

Code from Controller:

var fileTable = sap.ui.getCore().byId('noteFileTable');

var json = JSON.parse(fileTable.getModel().getJSON());

            for (var i = 0; i < indices.length; i++) {

                var context = searchTable.getContextByIndex(indices[i]).getPath();

                var model = searchTable.getModel();

                var obj = model.getProperty(context);

                obj.__metadata = null;

                if (!doFilesContainFile(json.results, obj)) {

                    json.results.push(obj);

                }

            }

            fileTable.getModel().setData(json);

            fileTable.bindRows("/results");

   addTableColumn(fileTable, "ACTIVATED_AT", "Activated at");

All I need to do is to modify "Activated at" field to display in format "yyyy-MM-dd HH:mm:ss.ms"

I have used date formatter at another place but its not working here. When I tried following code, the popup is not getting displayed.

  addTableColumn(new sap.ui.table.Column({

            label: new sap.ui.commons.Label({

                text:  "Activated at"

            }),

        //Date modification   

             template: new sap.ui.commons.TextView().bindProperty("text", {                         

             path: 'ACTIVATED_AT',

             type: new sap.ui.model.type.Date({pattern:"yyyy-MM-dd HH:mm:ss.ms"})

            })

        }));

Any help would be much appreciated.

Regards

Uday

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Uday,

Checkout this demokit link, SAPUI5 Explored

It might be useful for you.

Regards,

Sharique

Former Member
0 Kudos

Sharique,

if I am forcing to convert the date format, its throwing the error as mentioned above.

Regards

Uday

Former Member
0 Kudos

Hi Uday,

Can you please rewrite the code like this and check,

template: new sap.ui.commons.TextView().bindProperty("text", {                        

             path: 'ACTIVATED_AT',

             formatter : function(value){

                           var oLocale = sap.ui.getCore().getConfiguration().getLocale();

                    var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({

                           style : "medium",

                           pattern : "yyyy-MM-dd HH:mm:ss.ms"

                     }, oLocale);

                    var date = new Date(value);

                    var oDate = oDateFormat.format(date);

                    return oDate;

             }

})

Regards,

Sharique

santhu_gowdaz
Active Contributor
0 Kudos
former_member182372
Active Contributor
0 Kudos

what is value of ACTIVATED_AT?

Former Member
0 Kudos

Its an element from oData model.  The value of the field is the system date and time when a particular record is created. The format of this date an time is "Tue Jun 30 2015 09:20:13 GMT-0700 (Pacific Daylight Time)", however, we want to display this date in the format "2015-06-30 09:20:13:2013".

former_member182372
Active Contributor
0 Kudos

if that`s the element from odata what`s the type? edm.dateTime?

Former Member
0 Kudos

I am not sure. The model is XS odata model and in the files I can find exactly. Can you help me where I can look for its data type.

former_member182372
Active Contributor
0 Kudos

you can see it in $metadata of that OData service