I'm using c sharp and mysql.
when i'm trying to insert a date from DateTime type to date colum开发者_StackOverflow社区n in DB all i get is 0000-00-00
i'm parsing my DateTime like this : sessionDate.ToShortDateString()
but getting empty date ...
any help please
MySql uses date in yyyy-MM-dd format,So U can overide the toString() method Of DateTime.Now property.
YourDate= DateTime.Now.ToString("yyyy-MM-dd");
Try this to format your date time to a string value that is acceptable to MySQL
String.Format("{0:yyyy-MM-dd}", sessionDate);
精彩评论