cancel
Showing results for 
Search instead for 
Did you mean: 

The given date instance isn't valid

Former Member

my view code:

<ObjectAttribute

title="{i18n>dateTitle}"

text="{

path: 'invoice>ShippedDate',

type: 'sap.ui.model.type.Date',

formatOptions: {

style: 'long',

source: { pattern: 'yyyy-MM-ddTHH:mm:ss' } } }"/>

ShipppedDate information:

<d:ShippedDate m:type="Edm.DateTime">1997-10-13T00:00:00</d:ShippedDate>

when i run my project , the erroe occured,the error information is :The given date instance isn't valid

please give me a hand,thank you!

Accepted Solutions (0)

Answers (6)

Answers (6)

former_member611149
Discoverer

Hi,

Try this

<ObjectAttribute
	title="{i18n>dateTitle}"
	text="{
	path: 'invoice>ShippedDate',
		type: 'sap.ui.model.type.Date',
		formatOptions: {pattern: 'yyyy-MM-dd'}
	}"/>

pattern can be 'yMd' or 'yMdhms' or etc..

See

  • Documentation > Date and Time Related Controls: Data Binding
  • DateFormat > getDateInstance > format? Description

Hope it helps.

Hi Alila,

May be you can try with this formatoptions:

{source:{pattern:"timestamp"}, pattern:"yyyy-MM-dd"}
Former Member

thanks your answer, using one row code just as yours , the app run well, can show the date information, but the date format is not my need, we need the pattern like

pattern: 'yyyy-MM-ddTHH:mm:ss'

the following code occured the error:

<mvc:View
	controllerName="sap.ui.demo.wt.controller.Detail"
	xmlns="sap.m"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:wt="sap.ui.demo.wt.control">
	<Page
		title="{i18n>detailPageTitle}"
		showNavButton="true"
		navButtonPress="onNavBack">
		<ObjectHeader
			responsive="true"
			fullScreenOptimized="true"
			number="{
				parts: [{path: 'invoice>ExtendedPrice'}, {path: 'view>/currency'}],
				type: 'sap.ui.model.type.Currency',
				formatOptions: {
					showMeasure: false
				}
			}"
			numberUnit="{view>/currency}"
			intro="{invoice>ShipperName}"
			title="{invoice>ProductName}">
			<attributes>
				<ObjectAttribute title="{i18n>quantityTitle}" text="{invoice>Quantity}"></ObjectAttribute>
				<ObjectAttribute title="{i18n>dateTitle}" text="{
					path: 'invoice>ShippedDate',
					type: 'sap.ui.model.type.Date',
					formatOptions: {
					  style: 'long',
					  source: {
						pattern: 'yyyy-MM-ddTHH:mm:ss'
					  }
					}
				  }"/>
			</attributes>
		</ObjectHeader>
		<wt:ProductRating class="sapUiSmallMarginBeginEnd" change="onRatingChange"/>
	</Page>
</mvc:View>

Please give me hand.

0 Kudos

it's means you Date type field haven't nullable attribute, you should go to your entity and set Nullable = true

Former Member
0 Kudos

the '{invoice>ShippedDate}' come from :https://services.odata.org/V2/Northwind/Northwind.svc/Invoices

iftah_peretz
Active Contributor
0 Kudos

Hi,

As I can only see part of the code, can you tell me if the problem persists if you replace ObjectAttribute with this

<ObjectAttribute title="Test title" text="{ path: 'invoice>ShippedDate' }"/>

The clear point is to narrow it down to the place where the problem arises.