Linq query show output 0

I use linq query as below. but output show 0

IntDrRowCount = (From r In DtCaseCA.AsEnumerable
Where r(“Due date”).ToString < StrFilterDate1
Select r).Count

variable StrFilterDate1 as string 05/06/2021
Column Due date in file excel format as date.

data filter2.xlsx (36.7 KB)
DateFilter.xaml (17.0 KB)

Please guide me about it.

Hi @fairymemay

conver to date using cdate or date.parse and try again…

Thanks

@prasath_S convert StrFilterDate1 right ?

both r(“Due date”).ToString and strFilterDate1

@prasath_S SAME, SHOW 0

DateFilter.xaml (17.0 KB)
input.xlsx (20.3 KB)

Please guide me for how to solve it.

@fairymemay - please refer this post

@fairymemay - The reason why it is not working is, your cell format is “Date” type.

As you know, Initially i have provided the code with ‘Date’ format later you changed it to ‘General’ type…and then I gave another code.

But this input shows the cell type as Date again, that’s why it is not working. please use “preserve format” while reading and try to adjust the code.

@prasath17 Now , I change code to ‘Date’ format as below.

image

But If I run I show error.

image

Hi @fairymemay
check whether this is working fine or not
IntDrRowCount = (From r In DtCaseCA.AsEnumerable
Where CDate(r(“Due date”)).ToString(“dd/MM/yyyy”) < StrFilterDate1
Select r).Count

1 Like