Solved

Handling SharePoint DateTime columns

Posted on 2013-05-16
1
1,066 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
1 Comment
 
LVL 18

Accepted Solution

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Synchronize a new Active Directory domain with an existing Office 365 tenant
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now