i_dtData.Columns.Remove(“DueDatebyDate”) Dim filteredValues As DataTable = view.ToTable()
o_dtData = filteredValues
This is the error: RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.Data.EvaluateException: Cannot perform ‘<=’ operation on System.DateTime and System.String.
Attached you will find the picture of Datatable sample.
Thanks.
Br.
Marco.
Hi Peter, thanks for your answer … I’m stuck here …
RemoteException wrapping System.FormatException: String ‘30.01.2023 06:32:00’ was not recognized as a valid DateTime.
that’s the code:
dtData.Columns.Add(“DueDatebyDate”, GetType(DateTime))
For Each row In dtData.Rows
strDate = row(i_columnName).ToString
trimDate = strDate.Trim().ToString
i_formatDateTime = i_formatDateTime + " HH:mm:ss"
row(“DueDatebyDate”) = Date.ParseExact(trimDate + " 06:32:00", i_formatDateTime, System.Globalization.CultureInfo.InvariantCulture)
and that’s the i_formatDateTime: dd.MM.yyyy
I’m using ParseExact with invariant culture so I do not understand what’s wrong with it? it should consider only what I’m passing as argument.
Do you have any idea?
Thanks.
Marco.
then the format string should also define the time part
dd.MM.yyyy HH:mm:ss
Kindly note:
the last info looks different from the origin topic post. The relationship cannot be derived so far. We recommend to scope 1 topic = to one case along with a clear requirement desacripton and samples.
Hi Peter,
at the end I have realized the issue was not in the content but in the view.rowFilter construction maybe something with double quotes or similar you can see in my first post … so I have decided to switch the logic to LINQ you can see below and that’s works! Thanks for your tips!
’ Collection is a table (InputColl)
Dim row As DataRow
Dim strDate, trimDate As String
For Each row In dtData.Rows
strDate = row(i_columnName).ToString
trimDate = strDate.Trim().ToString
row(“DueDatebyDate”) = Date.ParseExact(trimDate, i_formatDateTime, CultureInfo.InvariantCulture)
Next
Dim query = _
From trans In dtData.AsEnumerable() _
Where trans.Field(Of DateTime)(“DueDatebyDate”) <= Date.ParseExact(DateTime.Now.AddDays(- i_thresholdDaysOverdue).ToString(i_formatDateTime), i_formatDateTime, CultureInfo.InvariantCulture) _
Or trans.Field(Of DateTime)(“DueDatebyDate”) > Date.ParseExact(DateTime.Now.ToString(i_formatDateTime), i_formatDateTime, CultureInfo.InvariantCulture) _
Select trans
Dim view As DataView = query.AsDataView()
Dim filteredValues As DataTable = view.ToTable()