Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

DateDiff in RowFilter

Hi,

I have a datagrid which has a column showing a date value "D1". I want to use the RowFilter to the dataview so that it will filter out records which have D1 older than a given number of days. The following is my RowFilter coding:

dv.RowFilter = "DateDiff(d, D1, DateTime.Today) <= 7"

However, when I execute it, .NET returns me an error: "The expression contains undefined function call DateDiff()". What's wrong??
[453 byte] By [THL] at [2007-11-11 7:33:41]
# 1 Re: DateDiff in RowFilter
Try this:

Dim FilterDate As DateTime = DateTime.Today.AddDays(-7)
dv.RowFilter = String.Format("D1 >= #{0}#", FilterDate.ToString("MM/dd/yyyy"))
Phil Weber at 2007-11-11 23:13:42 >
# 2 Re: DateDiff in RowFilter
Thanks Phil Weber, it really works.
THL at 2007-11-11 23:14:42 >