Hi
I want to filter a datatable containing rows with dates from this month, previous month and the one before that - result should be only rows from previous months
I would like to avoid for each activity since the rows that are removed are in the datatable same datatable.
I found another post (Delete data row from data table solved by @aksh1yadav ) and tried to make my own solution - but I cant get it to work.
Assign:
PnrSøgtTabel = PnrSøgtTabel.AsEnumerable.Where(Function (x) x.Item(“Navn”).ToString.Substring(5,2).Equals(Ind_FørsteDato.ToString.Substring(5,2))= True).CopyToDataTable
I get the error: startIndex cannot be larger than length of string.
Parameter name: startIndex
The datatable is named “PnrSøgtTabel”
Columnname with the date in the table is named “Navn” - (website is confused)
Sample date from “Navn”: 2019-08-07 08:49:16
Sample confirmation
Write line:
"Måned for Index “+(PnrSøgtTabel.Rows.Count -1).ToString+”: "+PnrSøgtTabel.rows(Convert.ToInt32(row.Item(“antal”))-1).item(“Navn”).tostring.Substring(5,2)
gives
Måned for Index 37: 06
I appriciate your time.