i have string token[5] = Aug and string token[6]=1 (see on image
)
i want to convert to DateTime.
i try:
DateTime DateCreated = DateTime.ParseExact(tokens[5] + tokens[6], "MM-dd", CultureInfo.InvariantCulture);
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.
There are a few issues:
tokens[5] + tokens[6].MMwould expect a two-digit month, for a three letter shorthand month useMMM.ddexpects a two-digit day (so in your case, 01 instead of 1). Usedto take one- or two-digit days.With all this said and done, you don’t actually need the hyphen:
Refer to this MSDN entry for more options:
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx