1
<m:Text text="{
  path: 'Begda',
  type: 'sap.ui.model.type.DateTime',
  formatOptions: {
    style: 'short'
  },
  constraints: {
    nullable: true,
    displayFormat: 'Date'
  }
}"/>

From the documentation I understood that I should use displayFormat: 'Date' to show the date only. The expected output is a localized display of day/month/year (or in another localized order).

The output that I get is 17/08/16 02:00.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Pieter
  • 1,751
  • 3
  • 30
  • 65
  • Possible duplicate of [OData Edm.DateTime - How to Display Date Only](https://stackoverflow.com/questions/50210037/odata-edm-datetime-how-to-display-date-only) – Boghyon Hoffmann May 16 '18 at 10:57

2 Answers2

1

You were very close. In order to display the date only..:

  1. Same as this question, you need to replace the regular type with the odata type: sap.ui.model.type.DateTime --> sap.ui.model.odata.type.DateTime.

    This class represents the OData V2 primitive type Edm.DateTime.

  2. And then use this constraint, as mentioned here:

    constraints: {
      displayFormat: 'Date'
    }
    

    About the displayFormat: 'Date':

    In this case, only the date part is used, the time part is always 00:00:00, and the time zone is UTC to avoid time-zone-related problems.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
0

Specify the pattern property and change the type property for sap.ui.model.type.Date:

<Text text="{path: '/someDate',
            type: 'sap.ui.model.type.Date',
            formatOptions: {
                source: {
                    pattern: 'yyyy-MM-ddTHH:mm:ss.AAAZ'   <-- Source property is optional
                },
            pattern: 'yyyy/MM/dd'
            }
        }" />