on ‎2021 Feb 27 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?
Request clarification before answering.
Hi,
Use the below sample code for reference.
In XML view:
<DatePicker id="SubmissionDate" value="{path: '/SubmissionDate', type:'sap.ui.model.type.Date', formatOptions:{ pattern : 'yyyy-MM-dd'}}" width="auto" displayFormat="medium" enabled="true" visible="true" valueFormat="yyyyMMdd" required="false"/>
In controller:
var sStartDt = new Date(this.byId("SubmissionDate").getValue());
or
var sNStartDt = (sStartDt.getFullYear()).toString()+'-' +(sStartDt.getMonth()+ 1).toString()+'-'+(sStartDt.getDate()).toString()+"T00:00:00Z"
Hope it helped you!
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Inside simpleform change the datepicker code to below.
<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" value="{path: '/SubmissionDate', type:'sap.ui.model.type.Date', formatOptions:{ pattern : 'yyyy-MM-dd'}}" width="auto" displayFormat="medium" enabled="true" visible="true" valueFormat="yyyyMMdd" required="false"/></f:content></f:SimpleForm>
inside the controller , get the date value as below.
var vTarih = new Date(this.byId("dpKayitTarih").getValue());
or
var vTarihDat = new Date(this.byId("dpKayitTarih").getValue(
var vTarih = (vTarihDat.getFullYear()).toString()+'-' +(vTarihDat.getMonth()+ 1).toString()+'-'+(vTarihDat.getDate()).toString()+"T00:00:00Z"
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.