---
title: "Insert date and time in European format into SQL Server from C#?"  
description: "Insert date and time in European format into SQL Server from C#?"  
author: "Anonymous User"  
published: 2013-07-15  
updated: 2013-07-16  
canonical: https://www.mindstick.com/forum/1291/insert-date-and-time-in-european-format-into-sql-server-from-c-sharp  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# Insert date and time in European format into SQL Server from C#?

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs)!

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](https://www.mindstick.com/forum/1763/string-format-with-null-values-c-sharp): \

![enter image description here](file:///C:/Users/SACHIN~1/AppData/Local/Temp/msohtmlclip1/01/clip_image001.jpg)

MY_TABLE has a DATE [column as](https://www.mindstick.com/forum/159334/how-to-set-column-as-auto_increment-in-mysql) a DateTime type.

I got this error:

**The [conversion](https://www.mindstick.com/forum/1734/conversion-from-32-bit-integer-to-4-chars) of a [varchar](https://www.mindstick.com/forum/161878/what-is-the-difference-between-nvarchar-and-varchar) data type to a [datetime data](https://www.mindstick.com/forum/266/datetime-data-type) 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](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by shreesh chandra shukla

Hello!\

better to use sql parameters

```
string sql = @"INSERT INTO MY_TABLE(DATE)
                            VALUES (@DATE)";
```

add the parameter to your SqlCommand

```
command.Parameters.AddWithValue("@DATE", myDate);
```


---

Original Source: https://www.mindstick.com/forum/1291/insert-date-and-time-in-european-format-into-sql-server-from-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
