Anything between the two #
characters in a RowFilter
expression will be ultimately passed into DateTime.Parse(s, CultureInfo.InvariantCulture)
.
This should be mentioned in the MSDN documentation for DataColumn.Expression
, but it isn't. However, if you dig really deep you can find it in the constructor of the internal class System.Data.ConstNode.
So as long as you are generating values that are unambiguous in the invariant culture, you should be fine. Just to be on the safe side, you might want to use the "s"
format specifier to give you a value like 2013-12-31T12:34:56
. Change your format string to "#{0:s}#"
.
Or much cleaner:
Dim TimeStr As String
TimeStr = Now.AddMinutes(-15).ToString("s", CultureInfo.InvariantCulture)
AlertsView.RowFilter = "StatusId < 3 AND LastEmailed < #" & TimeStr & "#"
String.Format
doesn't buy you much here.
Also - just out of curiosity, are you sure you are not comparing apples to oranges? It wouldn't be uncommon for a database to store UTC time in a field like LastEmailed
. You might need to use DateTime.UtcNow
instead of just Now
(which is an alias for DateTime.Now
).