Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with DataTable.Select

Status
Not open for further replies.

buddyel

MIS
Mar 3, 2002
279
US
I am trying to build a string to pass onto to a method that uses DataTable.Select and am running into an issue. The column i am trying to filter on is a datetime type. I tried using ColumnName = DateTime.Today but that returns nothing. I tried using between DateTime.Today and DateTime.Today.AddDays(1) but it throws an error saying "between" is not supported. How can i filter so that records with a Deadline of today are displayed? Any help is GREATLY appreciated.
 
Try
Code:
dataTable.Select(string.Format("ColumnName > #{0}# AND ColumnName < #{1}#)", DateTime.Today.ToString("MM/dd/yyyy 00:00:00"), DateTime.Today.ToString("MM/dd/yyyy 23:59:59")))
 
Oops, left a closing bracket in by mistake, should be:
Code:
dataTable.Select(string.Format("ColumnName > #{0}# AND ColumnName < #{1}#", DateTime.Today.ToString("MM/dd/yyyy 00:00:00"), DateTime.Today.ToString("MM/dd/yyyy 23:59:59")))
 
Shelton,

The code works great, does exactly what I needed.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top