问题
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.
回答1:
use this:
monthCalendar1.SelectionStart.Date.ToString("yyyy-MM-dd");
DateTime.ToString() accepts custom format as argument
来源:https://stackoverflow.com/questions/19735319/monthcalender-date-format-to-yyyy-mm-dd-c-sharp