DateTime filter in Dataview not matching RRS feed

  • Question

  • I want to filter a DataTable using a DateTime column and have run into a problem.  My date data is in Australian format ie dd/mm/yyyy and loads and saves from files as such.  Passing the full DataTable to a chart shows everything correctly.  I now want to filter the table and only chart a subset eg today's data.

    I've tried the following line which runs but produces an empty chart:

    chartView.RowFilter = String.Format(System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat, "DateCol = #{0}#", today)

    I've tried replacing it with the following line to ensure the actual values work but it produces an error - "string was not recognized as a valid DateTime":

    chartView.RowFilter = "DateCol = #23/09/2018 01:00:00 AM#"

    If I put the date into a US date format it then runs without errors but produces an empty chart again:

    chartView.RowFilter = "DateCol = #09/23/2018 01:00:00 AM#"

    This is odd as it's as if the filter is only working with US date formats even though the rest of my program is handling the default AUS date formats when being read/saved etc.  However, even though it runs with the US format, it then doesn't match correctly and produces an empty chart.


    Saturday, September 22, 2018 9:47 PM

All replies

  • Hi

    Give this a try:

    chartView.RowFilter = "DateCol = '" & Today & "'"

    Regards Les, Livingston, Scotland

    Saturday, September 22, 2018 10:33 PM
  • Hi Les, that code also runs without errors but I'm still getting a blank chart.  This is my first time playing with DataViews so I might be missing something else.  Having set the row filter, I'm then assigning it to the chart thus:

    graph.DataSource = chartView
    Is there anything else I need to do?  Before trying a DataView, I was just assigning the original DataTable to the graph's DataSource and that worked fine.
    Saturday, September 22, 2018 11:09 PM
  • Sounds like the chart is swallowing the en-AU date because (a guess) that it gets it's formatting from the current computer culture and the only way to know for sure is to set that computer up to en-AU culture. 

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Sunday, September 23, 2018 2:41 AM
  • Thanks all, I've solved the problem, though can't explain why it's thus.  Turns out the following line was making no results come back from the filtering process:

    chartView.RowStateFilter = DataViewRowState.Unchanged

    I don't know what this line is supposed to do but it was in the sample when I originally searched for help on setting up DataViews!

    Sunday, September 23, 2018 3:37 AM
  • Hi,

    Set filter to display only unchanged rows.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, September 24, 2018 2:43 AM