Need to convert a string to normal datetime format so it can be correctly inserted onto a datetime type field.
String Format:
4/21/2010 4:43:03 PM
Example:
2010-04-21 16:43:03.000
I have clarified question:
The need is to change format and not type.
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.
“Normal datetime” is a bit vague. Normal format is related to the culture you are running under.
Assuming your original string is parsable in your running culture, and you want to reformat it to the other string in your question you could do this:
[Edit – Forget the .ToString() part]
Re-read the question, and using parse will return a DateTime object which can be reused.