i’ve this string example value:
Sun, 09 May 2010 11:16:35 +0200
I’ve to insert it into MySql Date/Time field.
How can i convert it into .NET format (or Mysql format), so i can make my INSERT INTO mydate='2010-05-09 11:16:35' ?
Thank you !
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First you need to use
DateTime.Parse()to create a .NET DateTime object from the string value, as noted by others.Don’t be tempted to do something like:
It’s much better to build a parameterized query instead, not just in this case. It also makes sure that if you’re trying to insert/update text, you’re able to handle quotes correctly (instead of risking a sql injection possibility)