1

I have a database in MySQL. Now i want to insert value for a attribute of type data in in the database which is of the format yyyy-mm-dd.

I will be getting date from 'monthCalender'. Currently i am getting the date in format mm/dd/yyyy by using this code.

monthCalendar1.SelectionStart.Date.ToShortDateString()

How should i convert the format?

also i feel its weird for MySQL to ask for such a format. So i may be wrong. by the way am using XAMPP for the database.

4

1 回答 1

4

用这个:

monthCalendar1.SelectionStart.Date.ToString("yyyy-MM-dd");

DateTime.ToString()接受自定义格式作为参数

于 2013-11-01T21:01:18.100 回答