Solved

Handling SharePoint DateTime columns

Posted on 2013-05-16
1
1,116 Views
Last Modified: 2013-06-24
Hi Experts,

I am not sure how to handle properly with Powershell the SharePoint columns that are of type DateTime. I have 3 DateTime fields that differ slightly as follows but I notice the handline has to be separately done.

"Expiry Date" : A DateTime column that always have a value.
"Renewal Date" : A DateTime column that can have null.
"Notification Date" : A calculated column that returns Date only.

In Powershell, if I use
[DateTime] tmpDate = $item["Expiry Date"] --> this works
[DateTime] tmpDate = $item["Renewal Date"] --> this fail with cannot convert null to DateTime
[DateTime] tmpDate = $item["Notification Date"] --> this fails because it is not recognized as a date. Instead it is a string result, e.g. "datetime;#2005-01-26 00:00:00"


This is confusing. What is then the correct way to retrieve a date column from a SharePoint List?
0
Comment
Question by:NicksonKoh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
x-men earned 500 total points
ID: 39174956
if ($item["Renewal Date"] -ne "") {[DateTime] tmpDate = $item["Renewal Date"]}
[DateTime] tmpDate = get-date ($item["Notification Date"])
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question