Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How do I get an empty dateTime field from a SharePoint list?

$
0
0

I currently have a code that retrieves data from a custom SharePoint list. Part of the data that I am getting is a date field, and I am getting it by doing this...

DateTime myDate = DateTime.Parse(myItem["MyDateField"].ToString());
At first, this seems to work just fine. However I noticed that if there is no data in the date field, then a nullException reference is thrown. What is the best way to handle this, to return just a blank or empty date as the default once there is no data in the field. Thanks for the help.

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>