0

I have 2 sap.m.DatePicker objects in my XML view. I set the format to

sap.ui.model.odata.type.Date

based on the documentation in the following address sap.ui.model.odata.type

<DatePicker value="{ path: 'Validtodate', type : 'sap.ui.model.odata.type.Date'}" />

But still, I don't know why it shows date and time instead of date

Thanks in advance.

Inizio
  • 2,226
  • 15
  • 18
  • Does this answer your question? [OData Edm.DateTime - How to Display Date Only](https://stackoverflow.com/questions/50210037/odata-edm-datetime-how-to-display-date-only) – Boghyon Hoffmann Jul 17 '21 at 13:05

1 Answers1

0

It is actually a common problem in SAPUI5 applications. It is because of the type that you selected for your controller. Edit your XML code like this:

<DatePicker value="{ path: 'Validtodate', type : 'sap.ui.model.type.Date'}" />
MJBZA
  • 4,796
  • 8
  • 48
  • 97
  • This really depends on the type of the data source. If it's an OData service, using `sap.ui.model.odata.*` types is not a problem but the intended solution by UI5. E.g. if the `Validtodate` is a property of V4 type `Edm.Date`, the proper type is in fact `sap.ui.model.odata.type.Date` ([API ref](https://openui5.hana.ondemand.com/#/api/sap.ui.model.odata.type.Date)). The question author needs to provide more information whether the data is coming from an OData at all. – Boghyon Hoffmann Feb 11 '19 at 14:59
  • But I had exactly the same problem in oData service in SAP ERP systems. – MJBZA Feb 11 '19 at 15:04
  • Having problems when using the proper types suggests that the backend services were either not OData compliant or improperly configured. Anyhow, the topic [_Date and Time Related Controls: Data Binding_](https://ui5.sap.com/#/topic/e1ddc69c01474faf830a522db8c9238a) as well as the [API reference](https://ui5.sap.com/#/api/sap.ui.model.odata.type) suggests to use `sap.ui.model.odata` types corresponding to the EDM type of the entity property. – Boghyon Hoffmann Feb 11 '19 at 15:22