question

JayashriThorat-2322 avatar image
0 Votes"
JayashriThorat-2322 asked JayashriThorat-2322 answered

cannot convert a prmitive value to the expected type 'Edm.DateTime'

Hello All,

I am creating custom list form using js and HTML.

I am getting error mentioned in the title as : cannot convert a prmitive value to the expected type 'Edm.DateTime'

Below is the code, for checking on date thing:

**vDate and tillDate are variable declared for 2 dates existing column in list.
var todayDate = new Date();
var currentDate = todayDate.getFullYear()+ '-' + ((todayDate.getMonth() > 8) ? (todayDate.getMonth() + 1) : ('0' + (todayDate.getMonth() + 1)))+ '-' + ((todayDate.getDate() > 9) ? todayDate.getDate() : ('0' + todayDate.getDate()));

if( vDate >= currentDate)
{
if( tillDate >= currentDate)
{
var date = new Date(vDate);
date.setDate(date.getDate() + 7);
var third_date = moment(date).format('YYYY-MM-DD');
var fourth_date = third_date.toString();
if (tillDate <= fourth_date && tillDate >= vDate) {
{
saveAction();
location.reload();
}
else{
}
}**


Please assist.

Thanking in advance

Regards,
Jayashri

office-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JayashriThorat-2322 avatar image
0 Votes"
JayashriThorat-2322 answered

Sorry for replying late.

This problem/error occurred as a result of a blank value in the Date column.
As a result, the problem was solved by inserting "Null" if the Date column value was blank.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered MichaelHan-MSFT commented

Hi @JayashriThorat-2322

In sharepoint, the datetime column are in ISO8601 format (YYYY-MM-DDTHH:MM:SSZ). You could format the column like this:

  moment(date).format('YYYY-MM-DDTHH:mmZ')



If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JayashriThorat-2322,

Is there anything update? Did my solution work for you?

0 Votes 0 ·