Solved

Handling SharePoint DateTime columns

Posted on 2013-05-16
1
1,070 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
ID: 39174956
if ($item["Renewal Date"] -ne "") {[DateTime] tmpDate = $item["Renewal Date"]}
[DateTime] tmpDate = get-date ($item["Notification Date"])
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

19 Experts available now in Live!

Get 1:1 Help Now