Format of DateTime that SQL Server uses

I am debugging a query that is getting built in C# maybe with EntityFrameWork - not sure - but it doesn't return any records although it should. The query has some DateTime fields and they are like this:

personStartDate   {4/3/2013 12:00:00 AM}

The value for Date is getting from user interface date picker but I guess it also defaults the time part to 12:00:00 AM somehow.

Then I go to SQL Server and view the table rows and values on their datatime field data looks like this example: '2013-04-23 09:20:38.897'

Do you see any obvious problem right there? Also I am trying to take the generated SQL from my breakpoint in C# and post it to SQL Server to see what does it return so for a value like {4/3/2013 12:00:00 AM} I am replacing it with 2013-04-03 12:00:00.000 Is that even correct?

Jon Skeet
people
quotationmark

Formatting is irrelevant. Internally it won't be in a text format at all, and I'd hope that the query doesn't end up sending the query value to the database as text either.

If you're only interested in the date part, you need to say that in the query:

where foo.Start.Date == personStartDate

(for example - we don't know what your query looks like).

If your field in the database is logically just a Date but is currently a DateTime, you should consider changing your schema to match your logical data model. It'll make things simpler.

people

See more on this question at Stackoverflow