Hi,
**********************************************************
string str = "20081231113000"
ApplicationDate = DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
****************************************************************
The above code works fine and provides the application date in the format that I need. However sometimes str is blank. In that case the program throws an exception that the string is in invalid format.
How can I change this code so that it will parse and give me the date if available and if the date is unavailable assigns a value of null or minvalue for the applicationdate.
Would a Try Catch be a good approach? or is there a better way?
Thanks
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.