Home All Groups Group Topic Archive Search About

RowFilter on a DateTime value (both Date & Time)

Author
8 Dec 2004 10:57 PM
FinallyInSeattle
I have the need to be able to filter a DataTable on a column being between
two datetime values.  The following works if there is no time stored :

string strRowFilter = "StartDate <= " + dtStart.ToString() + " AND " +
"EndDate >= " + dtEnd.ToString();

However, dtStart or dtEnd has a time, then I get a "Unhandled Exception:
System.Data.SyntaxErrorException: Syntax error: Missing operand after '12'
operator." (the time in dtStart is 12:00:00).

How do I format the RowFilter string to handle both a date and time value?

Thanks in advance!

AddThis Social Bookmark Button