troubleshooting Question

C# Date.ParseExact Question

Avatar of moosetracker
moosetracker asked on
.NET ProgrammingC#Visual Basic.NET
21 Comments2 Solutions490 ViewsLast Modified:
I am trying to convert a string to a date with an "am"/"pm" in it..  What I have created seems to work fine if the date/time is hardcoded in...

ftpDateTime = DateTime.ParseExact("1/25/14 06:33PM", "M/d/yy hh:mmtt", CultureInfo.InvariantCulture);

But NOT when the datetime is in a string field, even though the dates in both match exactly. I get a format error.. (see attached image showing date in the string field & error).

ftpDateTime = DateTime.ParseExact(dspDate, "M/d/yy hh:mmtt", CultureInfo.InvariantCulture);

Does anyone know WHY???     Thanks..

DateTimeParse Example
Join our community to see this answer!
Unlock 2 Answers and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros