Filtering by date with DataTable.RowFilter while ignoring time

Sam picture Sam · Mar 11, 2010 · Viewed 6.9k times · Source

How do I filter for records on a DataTable which are on a certain date?

I've tried plain [datecol] = #11 March 2010# and CONVERT([datecol],'System.DateTime') = #11 March 2010#. With no luck.

MSDN: RowFilter Expression Syntax

Solution

[datecol] >= #11 March 2010 00:00# AND [datecol] <= #11 March 2010 23:59:59#

Answer

CResults picture CResults · Mar 11, 2010
select 
   ...
   ...
   ...

where [datecol] between '11 March 2010 00:00:00' and '11 March 2010 23:59:59'

Sorry, wrong head on. Just been writing a LOT of SQL!!

Try this

[datecol] >= #03/11/2010 00:00:00# AND [datecol] <= #03/11/2010 23:59:59# 

or

 [datecol] >= '03/11/2010 00:00:00' AND [datecol] <= '03/11/2010 23:59:59'