Hi,
The default format of sql is MM/DD/YYYY. So it is good to construct a sql query with the default format. Like MySql db we don't have any Date Format.
Sample Query:
SQL Server/Ms Access Database:
INSERT INTO tbl_tableName (Name,Address,DateOfBirth) VALUES('John','Trichy','11/31/2011');
MySql Database:
public class MySQLDateFormat
{
public const string MONTH_DATE_YEAR = "%m/%d/%Y";
public const string MONTH_DATE_YEAR_SEC = "%m/%d/%Y %H:%i:%s";
public const string DATE_MONTH_YEAR = "%d/%m/%Y";
public const string DATE_MONTH_YEAR_SEC = "%d/%m/%Y %H:%i:%s";
public const string YEAR_MONTH_DATE = "%Y/%m/%d";
public const string YEAR_MONTH_DATE_SEC = "%Y/%m/%d %H:%i:%s";
public const string HOUR_MINUTE_SECONDS = "%H:%i:%s";
public const string HOUR_MINUTE_SECONDS_AM_PM = "%H:%i:%s";
}
Query:
INSERT INTO tbl_tableName (Name,Address,DateOfBirth) VALUES('John','Trichy',DATE_FORMAT('11/31/2011','%m/%d/%Y');
Note:
You can have a separate class like I have given above and concadinate in the date format place.