tags:

views:

46

answers:

2

I am using C# code for inserting record and datetimepicker control for Date I want to insert Date like 24-05-2010 in MySQL Database What Datatype i have to use for that in MySQL table

and how to right insert query for to insert date?

A: 

You should use the DATE datatype, which by default will retrieve it as 2010-05-24 when you get the value as a string. If you need that specific format you mentioned, you can either store it as a VARCHAR(10) or use a function (e.g. DATE_FORMAT('%d-%m-%y')) when getting the value from the table.

Senseful
i am developing window application using visual studio and c# i want to insert date in Mysql database table which having datatype dateusing datetimepicker control of visual studioi wrote insertquery like this (insert into table name values('"+ datetimepicker.value + "')it give me following errorERROR [HY000] [MySQL][ODBC 3.51 Driver][mysqld-5.1.47-community]Incorrect datetime value: '01-06-2010 00:00:00' for column 'Date' at row 1can any one resolve this problem
+5  A: 

No, you don't want it :) Are you really concerned of the format in which data will be stored?

I am sure you want to use 2010-05-24 format and date date field type.

While if you want to display it back in your own format, you can use a date_format() function in your SELECT query

Col. Shrapnel
Yeah, ISO-8601 dates only. Not UK style dates, or US style dates. Just ISO-8601.
MarkR
i am developing window application using visual studio and c# i want to insert date in Mysql database table which having datatype dateusing datetimepicker control of visual studioi wrote insertquery like this (insert into table name values('"+ datetimepicker.value + "')it give me following errorERROR [HY000] [MySQL][ODBC 3.51 Driver][mysqld-5.1.47-community]Incorrect datetime value: '01-06-2010 00:00:00' for column 'Date' at row 1can any one resolve this problem