Question: i need to check for a specific DateTime value in my table from my code (VB.NET) and i don't know how to format the DateTime as a string. i've read that SQL Server will recognize my string if it's in either date, time, or date and time format. i mean:

```
'May 15, 2004'
'5/15/2004'
'20040515'
'2004 4 am'

```

will SQL Server recognize these strings as valid DateTime values? i'm curious because if i check the actual DateTime values in the table they are in this format:

```
2/2/2006 3:49:33 PM

```

Answer: 
If not using a parameterized query, use [CAST/CONVERT](http://msdn.microsoft.com/en-us/library/ms187928.aspx) to explicitly change a string to a DATETIME:

```
SELECT CAST('2/2/2006 3:49:33 PM' AS DATETIME)

```

On my SQL Server 2005, that returns to me:

```
2006-02-02 15:49:33.000

```

Mind that the default date format in SQL Server can be different than what you provide.
This has always been safe that I have found:
YYYY-MM-DD HH:MI:SS