---
title: "C# DateTime MySQL Command"  
description: "C# DateTime MySQL Command"  
author: "Anonymous User"  
published: 2013-12-12  
updated: 2013-12-12  
canonical: https://www.mindstick.com/forum/1766/c-sharp-datetime-mysql-command  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# C# DateTime MySQL Command

I am having [issues](https://www.mindstick.com/articles/12944/mattresses-for-kids-and-mothers-should-meet-certain-criteria-issues-you-should-consider) with using the [DateTime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) as the [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) to work for a [sql query](https://www.mindstick.com/forum/529/rename-table-name-and-column-name-using-sql-query).

Here is the query I would like :

command.CommandText = "[SELECT](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) idGameNumber FROM GameOutcome WHERE GameOutcome.gameDate = <[insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net) DateTime game_time>";

where game_time is a DateTime object and Gameoutcome.gameDate is a DATETIME datatype.

What do I need to put on the [right](https://www.mindstick.com/articles/12766/check-whether-you-are-doing-digital-transformation-right-or-not) side of the = sign in there [WHERE clause](https://www.mindstick.com/interview/1909/when-do-you-use-where-clause-and-when-do-you-use-having-clause)?

## Replies

### Reply by Pravesh Singh

Hi jayPrakash,\
\

using DateTime string

MYSQL takes the DateTime in Following default format:

yyyy-MM-dd HH:mm:ss

so you can convert your datetime object into above format.

## Try This:

```
command.CommandText ="SELECT idGameNumber FROM GameOutcome WHERE GameOutcome.gameDate ='"+ game_time.ToString("yyyy-MM-dd HH:mm:ss")+"'";
```


---

Original Source: https://www.mindstick.com/forum/1766/c-sharp-datetime-mysql-command

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
