DataView filter datetime

  • Thread starter Thread starter Duggi
  • Start date Start date
D

Duggi

Hi

I have a dataview dv, in which one of the column is a date time
column.

I would like to apply filter on this column. The filter should be some
thing like

"All the rows that has the date time between DATE1 and DATE2".

Please some one help me.,

Thanks
-Cnu
 
Cnu,

Check the documentation for the Expression property on the DataColumn
class. This is what the syntax for the RowFilter property on the DataView
class will use. Specifically, your filter will be something like:

dataView.RowFilter = "dateTimeColumn >= #mm/dd/yyyy# and dateTimeColumn <
#mm/dd/yyyy#";

Some things to note. First, the format of the date should be in the
current local. So if you are using dd/mm/yyyy, then use that.

The other thing to note is that I wasn't sure if you wanted DATE2 to be
inclusive or not. If you did, and you have time values, then you are going
to have to use less than for the second operator, and your DATE2 should be
DATE2 plus one day.
 
Cnu,

    Check the documentation for the Expression property on the DataColumn
class.  This is what the syntax for the RowFilter property on the DataView
class will use.  Specifically, your filter will be something like:

dataView.RowFilter = "dateTimeColumn >= #mm/dd/yyyy# and dateTimeColumn <
#mm/dd/yyyy#";

    Some things to note.  First, the format of the date should be in the
current local.  So if you are using dd/mm/yyyy, then use that.

    The other thing to note is that I wasn't sure if you wanted DATE2to be
inclusive or not.  If you did, and you have time values, then you are going
to have to use less than for the second operator, and your DATE2 should be
DATE2 plus one day.

--
          - Nicholas Paldino [.NET/C# MVP]
          - (e-mail address removed)




I have a dataview dv, in which one of the column is a date time
column.
I would like to apply filter on this column. The filter should be some
thing like
"All the rows that has the date time between DATE1 and DATE2".
Please some one help me.,
Thanks
-Cnu- Hide quoted text -

- Show quoted text -

Thanks for the help. It worked for me. The dates are converted on
locale and then compared. I hope I do not run into issues in future.

Thanks
Cnu
 
Back
Top