Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
my date string is
June 17, 2014


i want to conver it in DateTime

string fromDate= "June 17, 2014";
string format = "MMM dd, yyyy";
 DateTime date = DateTime.ParseExact(fromDate, format, CultureInfo.InvariantCulture);


Error is

String was not recognized as a valid DateTime.
Posted

Change this:
C#
string format = "MMM dd, yyyy";
to
string format = "MMMM dd, yyyy";
 
Share this answer
 
v2
Comments
Yogesh Kumar Tyagi 18-Jun-14 5:41am    
i change
from "MMM dd, yyyy" to "MMMM dd, yyyy".

Same error Through

String was not recognized as a valid DateTime.

Thanx Sir for Help i solve itself
Thanks7872 18-Jun-14 5:50am    
Its impossible. With your given details this code is garunteed to be true. Check again.
Yogesh Kumar Tyagi 18-Jun-14 6:55am    
yes, i checked Your code work

Thanks again.
DateTime fDate = DateTime.Parse(fromDate);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900