2

I am inserting the date to sharepoint lists date time column.

var StartDate=new Date($("#startDate").val()); //getting date from textbox in "2016-06-08"(yy-mm-dd) format and also tried other format

oListItem1.set_item('Start_x0020_Date',StartDate); //inserting to Start_x0020_Date column.

But in sharepoint list date is inserted one day before the actual date i.e 2016-06-07

2
  • Try changing the date column to date-time and see if the time component being saved is 23:00. Possible issue with daylight savings. – Nisarg Jun 10 '16 at 14:17
  • Is the time zone for the tenant set to a different time zone than the one you're in? We have this issue in our tenant, where we have it set to CST, when we are in EST. It has caused quiet some confusion. – wjervis Jun 10 '16 at 14:27
0

You can do this by workflows by following steps-

1- Create two column StartDate to your list(type single line of text).

2- Change your code by:

oListItem1.set_item('StartDate',StartDate);

3- Create a workflow to that list Create a workflow variable startDate and set its current item StartDate value.

Set Variable: startDate to Current Item:StartDate

4- and Update the list items as shown in SnapShots.

Update item in Current Item

Snap Shots:-

enter image description here

enter image description here

1

D,

I believe the date which you are referencing is your system date while SharePoint will consider server date time. also, javascript month starts from 0, so it might also be the cause to increment date by 1.

2
  • Date starts at 1, only month starts at 0. – wjervis Jun 10 '16 at 14:26
  • Ohh yes, sorry for that. – Farshid Mahdavipour Jun 10 '16 at 14:28
0

Format your input date with moment.js as follows.

oListItem1.set_item('Start_x0020_Date', moment(StartDate).format('YYYY-MM-DDTHH:mm:ssZ'))); 
//inserting to Start_x0020_Date column.
1
  • Should that be .format("yyyy-MM-ddTHH:mm:ssZ") vs .format('YYYY-MM-DDTHH:mm:ssZ') ? – Joe Johnston Feb 19 '20 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy