Reputation: 4783
I'm using c sharp and mysql.
when i'm trying to insert a date from DateTime type to date column 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
Upvotes: 0
Views: 2127
Reputation: 15851
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");
Upvotes: 1
Reputation: 125
Try this to format your date time to a string value that is acceptable to MySQL
String.Format("{0:yyyy-MM-dd}", sessionDate);
Upvotes: 0