0
I made a date comparison function. It compares the date of an input with a date column of a datatable. It follows the code:
Public Shared Function GetNextDiaUtil(d As Date) As Date
Dim feriados As DataTable = ManipulaDB.ConsultaSql("SELECT CAMPO2 FROM TAB_FERIADOS")
If d.DaysOfWeek = DaysOfWeek.Saturday Then
d = d.AddDays(2)
ElseIf d.DayOfWeek = DaysOfWeek.Sunday Then
d = d.AddDays(1)
End If
For Each data As DataRow In feriados.Rows
If d.Equals(CDate(data.ToString)) Then
d = d.AddDays(1)
End If
Next
Return d
End Function
The following error is released: Conversion from string "System.Data.Datarow" to type 'Date' is not Valid.
If instead of data.ToString
put a string as 07-09-2021
is compared correctly. How do I compare a type Date with a Datarow?
holidays. Rows I think this returns a collection so can’t just give a
toString
and also have to check via debug what is insidedata
– novic
CAMPO2 is of what type?
– novic
@novic the CAMPO2 is of type DATE in the database.
– Facalesta