I need to check if in a cell the month and year is bigger than current month and year. I mean, for example if now is 06/2022, if in the cell there is 01/2023 it should be caught. But if we have 12/2021 this one should not be caugth.
How can I do that with linq?
Thanks in advance!
What do you mean by caught here please ?
Create a datatable with the rows that pass the condition
(from r in dt.AsEnumerable where convert.ToDateTime(r(“date”)) > Now select r).CopyToDataTable
Thanks for the anwer @hckwon5! but I need from month+1 to onwards. I mean, if the current date is 10/06/2022, I need to get from 01/07/2022 onwards. I shouldn’t get 25/06/2022 for example and in the same year. Just in the current year. So in this case I should get from month 07 - 12
Hi @Angel_Llull ,
Could you Check if the Below Expression works :
DT.AsEnumerable.Where(Function(x)CDate(x("YourDateColumn").ToString).Month>Now.Month AndAlso CDate(x("YourDateColumn").ToString).Year<=Now.Year).CopyToDataTable
If there are errors related to Date, then we can use
DateTime.ParseExact() method to convert based on the date format present.
Let us know if it doesn’t work.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.