Change Date Column While Preserving Modified By Field in PowerShell

While working on an eRoom migration project, I noticed that the date stored in SharePoint is off by one day (technically 5 hours).

Date Processed in eRoom shows 1 Aug 2013 for items 1-5, 5 Aug 2013 for items 6-11, and so on…


After the data is migrated into SharePoint with Content Matrix eRoom Edition, Date Processed shows one day before.

Here you can see, instead of 8/1/2013 for items 1-5, and 8/5/2013 for items 6-11.  Date processed shows 7/31/2013 and 8/4/2013.  One day earlier than what was eRoom.


I could change the Regional Settings to accommodate this, but the settings will apply to all contents on the site.  This is not the goal I’m hoping to achieve.

I could also use Calculated column, but I have multiple lists with similar issue as this list, and I need to get them done fast.

So, I created a PowerShell script to do the work for me instead.  I need to meet two objectives with my script.

1. Change date by 1 day

2. Preserve Modified By value

Below is the final script that worked for me:

$web = Get-SPWeb "https://YourWeb"
$list = $web.Lists["ListName"]

ForEach($item in $list.Items)
  $oldDate = $item["Date Processed"]
  $interimDate = (Get-Date $oldDate)    #Allows me to call Get-Date methods
  $newDate = $interimDate.AddDays(+1)   #I could you AddHours or AddDays
  $item["Date Processed"] = $newDate
  $modifiedBy = $item["Editor"]
  $item["Editor"] = $modifiedBy

Here’s the final result in SharePoint.  Date Processed now matches eRoom and Modified By is unchanged.