I have here a little problem and would like to know where is my mistake and how to correct it.
string preConvDATE = monthCombobox2.Text + " " + datecombobox2.Text + ","+ "0000";
//lets say the comboboxes contain something like this "January 1";
DateTime DT = DateTime.ParseExact(preConvDATE, "MMMM d, yyyy 00:00:00", System.Globalization.CultureInfo.InvariantCulture);
string strDate = DT.ToString("yyyy-mm-dd");
try
{
//code that inserts strDate to a column in Mysql DB
}
catch
{
//msg
}
why "0000" for the year? because i was really planning to store just the month and date, but realized i could just store it as a datetime format with a year, and then at viewing the table i'd just use the Mysql MONTH() and DATE() function concatenated to view the Month and Date i stored from the monthCombobox2 and datecombobox2.
I also tried:
Convert.ToDateTime()
But still won't work.
How do i properly parse MMMM d,yyyy date format so that i could convert it to yyyy-mm-dd again and store it as datetime format in the database?
Thank you so much :)
DateTimeobject using its constructor), and then trying to parse that string, and reformat it as another string. This is a very strange thing to do.new DateTime(year, month, day)?