DateTime filter in Dataview not matching

  • Thread starter Thread starter Tyson Ackland
  • Start date Start date
T

Tyson Ackland

Guest
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.

Help!

Continue reading...
 
Back
Top