Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAriel Rzeszowski
5,482 PointsSystem.FormatException - DateTime cannot Parse
Hi,
Everything in this part is clever. But I noticed when DateTime use a TryParse method it's step over IF statment. I changed to Parse to see what is the problem and i saw this: System.FormatException. I think so problem is in my culture. Am I right ? I from Poland and perhaps a pattern of Date is diffrent in my culture.
Can you solve a problem ? There is any solution to do this ?
Sorry for my english.
This is pattern when i call DateTime.Now() : {10.09.2019 20:36:19} And this is pattern from our cvs file: {8/26/2015 05:30 PM}
I supposed that i need this one: public static bool TryParse(string s, IFormatProvider provider, DateTimeStyles styles, out DateTime result);
But i don't know how to change a parameters to avoid a exception
1 Answer
Steven Parker
231,269 PointsSomeone having a similar issue just yesterday posted this solution. Give that a try and see if it works for you also.