区分时间和日期的最佳方法是什么?

问题描述:

大家好,
我正在使用 SQL Server Compact Edition 做一个小型 ADO.NET/C#应用程序.
有一个带有 DateTime 字段的表,我想查询一个根据时间 date过滤数据的查询.

例如:我希望所有行的时间 1:00 am和2:00 am之间,并且日期 1/1/2010和10/1/2010之间.

我该怎么做 ?以及在哪里(在使用 Select()方法的应用程序的数据表中?还是在数据库中?)

Hi everyone,
I''m doing a small ADO.NET/C# application using SQL Server Compact Edition.
There''s a table with a DateTime field, and I want a query that filters data depending on time and date.

For example: I want all the rows with the time between 1:00 am and 2:00 am AND the date between 1/1/2010 and 10/1/2010.

How can I do it ? and where (in the application''s DataTable using Select() method? or in the database?)

在其中使用标准查询以在两个日期之间进行过滤,并在时间范围的datepart(hh,colname)过滤器中进行AND操作.
Use a standard where query to filter between the two dates, and also AND in a datepart(hh, colname) filter for the time range.