0

As the title says I need to change the year for all rows in a list to 2015 from 2014 but leave the month and day the same for each.

Had this been built as a calculated date column it would be much easier but it's just a normal date column and I can't figure out if what I want to do is possible.

Any help is greatly appreciated!

2
  • You can either use PowerShell or use CSOM for doing this. Jan 9, 2015 at 0:18
  • Open id Datasheet View(if 2010 version), or quick-edit mode if 2013, and ctrl+c, ctrl+v values there.
    – Gennady G
    Jan 9, 2015 at 12:52

2 Answers 2

0

You can follow below example using PowerShell

#Load necessary module to connect to SPOService
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null

#Login Information for script
$User = "[email protected]"
$Pass = "password"

$WebUrl = "https://site.sharepoint.com/"

#Connect to SharePoint Online service
Write-Host "Logging into SharePoint online service." -ForegroundColor Green

$Context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl)
$Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User, (ConvertTo-SecureString $Pass -AsPlainText -Force))

#Get the Necessary List
Write-Host "Getting the required list." -ForegroundColor Green
$List = $Context.Web.Lists.GetByTitle("VacationRequestForm")

$Query = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery(100); 
$Items = $List.GetItems($Query);

$Context.Load($Items);
$Context.ExecuteQuery();

#Edit existing list items
foreach($item in $Items)
{
    $item["DateColumn"] = ([datetime]$item["DateColumn"]).AddYears(1);
    $item.Update()
    $Context.ExecuteQuery();
}

Write-Host "Your changes have now been made." -ForegroundColor Green
1
  • Works great. I changed up the item limit on the createallitemsquery() method. But other than that this works great!! Thanks Amal!
    – Braden
    Jan 9, 2015 at 18:15
0

You could try opening the list in Excel or Access and making the changes there.

To do this, open the list in your browser (needs to be IE), from the ribbon click the List tab and then click either Export to Excel or Open in Access.

2
  • Wouldn't you have to re-import the spreadsheet and create a new list using this method?
    – Braden
    Jan 9, 2015 at 18:39
  • Certainly not if opened in Access, as I've done it via this method before. I presumed the same for Excel, although I don't have experience with this method.
    – Submits
    Jan 9, 2015 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.