String was not recognized as a valid DateTime. how to solve this problem .....in c# window application
11 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Nitin SontakkeRank #264 · 9.6K reputationPosted Nov 14, 2016, 8:10 PM EST
✓ Accepted answer+1
As I keep observing everywhere, date is probably most misunderstood data type.
What is the datatype of "Dates" column in table. Because both SQL Server and C# support datetime, try not to convert dates to strings at all.
Remember that the regional settings of your computer play a role in such conversions. Computers have problem converting dates like '09/02/2016'. Is it 9th February or 2nd September? That is decided by computer regional settings. Your sql server may have different regional settings than yours!
If you have to convert dates to string, for programming purpose, always stick to just one format yyyy-MM-dd. Formats like dd-MM-yyyy or MM-dd-yyyy are error prone.
+1
Harshal PatilRank #9,687 · 203 reputationPosted Dec 8, 2016, 12:13 AM EST
Nitin SontakkeRank #264 · 9.6K reputationPosted Nov 14, 2016, 8:10 PM EST
Harshal PatilRank #9,687 · 203 reputationPosted Dec 8, 2016, 12:13 AM EST
Shuvojit HalderRank #2,827 · 503 reputationPosted Nov 14, 2016, 1:21 AM EST
Nitin SontakkeRank #264 · 9.6K reputationPosted Nov 14, 2016, 1:23 AM EST
Salman BegRank #284 · 8.8K reputationPosted Nov 14, 2016, 1:31 AM EST
V S N Raju KanumuriRank #8,839 · 215 reputationPosted Nov 14, 2016, 4:28 AM EST
Manas MohapatraRank #182 · 13.2K reputationPosted Nov 14, 2016, 4:54 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Nov 14, 2016, 9:45 AM EST
Jitendra SharmaRank #3,268 · 439 reputationPosted Nov 14, 2016, 8:02 PM EST
Nitin SontakkeRank #264 · 9.6K reputationPosted Nov 14, 2016, 8:16 PM EST
Jitendra SharmaRank #3,268 · 439 reputationPosted Nov 14, 2016, 8:33 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts