forum

Home / DeveloperSection / Forums / Insert date and time in European format into SQL Server from C#?

Insert date and time in European format into SQL Server from C#?

Anonymous User 3859 15-Jul-2013
Hi Developers!

Here's my query:

string sql = @"INSERT INTO MY_TABLE(DATE) 
                            VALUES (convert(datetime, '{0}')";
 
sql = string.Format(sql, myDate);

myDate is a C# DateTime object and has this value before the string.format: 

Insert date and time in European format into SQL Server from C#?

MY_TABLE has a DATE column as a DateTime type.

I got this error:

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

I need to store the myDatevalue in a format like: 31/12/2013 23:59:00 into MY_TABLE.

thanks in Advance


Updated on 16-Jul-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By