on 02-27-2021 1:22 AM
I want to show the date I got with DatePicker in a section in a table. But the date is missing 1 day.
I tried many methods:
https://answers.sap.com/questions/409976/sap-webide---ui5---date-field-is-not-showing-corre.html
https://answers.sap.com/questions/323063/date-value-is-getting-reduced-by-one-day-while-pas.html
But it didn't work. What is your suggestion?
Since there is no code, I assume the binding info of the DatePicker is not consistent with the binding info of the Text within the table. It's important to keep them consistent.
If the values are bound with a v2.ODataModel, use:
<DatePicker/Text xmlns="sap.m"
xmlns:core="sap.ui.core"
core:require="{ ODataDateTimeType: 'sap/ui/model/odata/type/DateTime' }"
value/text="{
path: 'EntryDate',
type: 'ODataDateTimeType',
constraints: {
displayFormat: 'Date'
}
}"
/>
Please follow the documented guidelines "Dates, Times, Timestamps, and Time Zones" — must-read for OData V2 and OData V4.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your answer but it didn't work. Where am I doing wrong?
<!--It's a input on my fragmnet-->
<f:SimpleForm editable="true" layout="ResponsiveGridLayout" labelSpanXL="3" labelSpanL="3" labelSpanS="12" adjustLabelSpan="false" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1" singleConteinerFullSize="false">
<f:content>
<DatePicker id="dpKayitTarih"/>
</f:content>
</f:SimpleForm>
<cells>
<!--My code-->
<!--<Text text="{ path: 'Tarih', type: 'sap.ui.model.type.Date', formatOptions: { pattern: 'MM/dd/yyyy' } }" />-->
<!--Your code-->
<Text xmlns="sap.m" xmlns:core="sap.ui.core" core:require="{ ODataDateTimeType: 'sap/ui/model/odata/type/DateTime' }" text="{ path: 'Tarih', type: 'ODataDateTimeType', constraints: { displayFormat: 'Date' } }"/>
</cells>
sehergurel The value-property in DatePicker should be also bound with the v2.ODataModel as suggested in my answer.
The above steps are part of the standard approach of dealing with OData binding.
If it requires too many changes in your code, forget all the above steps and try adding `UTC: true` to your Text.
<Text text="{
path: 'Tarih',
type: 'sap.ui.model.type.Date',
formatOptions: {
...,
UTC: true
}
}" />
Boghyon's solution definitely works. It's pretty charming you can stick to Databinding and keep away any coding here.
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.