DataView filter datetime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Duggi

    #1

    DataView filter datetime

    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
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: DataView filter datetime

    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.RowFil ter = "dateTimeCo lumn >= #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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Duggi" <DuggiSrinivasa Rao@gmail.comwr ote in message
    news:b1a69568-f17c-4f55-9e1e-368eb9b7fa07@c2 2g2000prc.googl egroups.com...
    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

    Comment

    • Duggi

      #3
      Re: DataView filter datetime

      On Nov 10, 10:33 pm, "Nicholas Paldino [.NET/C# MVP]"
      <m...@spam.guar d.caspershouse. comwrote:
      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.RowFil ter = "dateTimeCo lumn >= #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]
                - m...@spam.guard .caspershouse.c om
      >
      "Duggi" <DuggiSrinivasa ...@gmail.comwr ote in message
      >
      news:b1a69568-f17c-4f55-9e1e-368eb9b7fa07@c2 2g2000prc.googl egroups.com...
      >
      >
      >
      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- 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

      Comment

      Working...