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.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
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.
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.