Date format - Filter datatable

I want to keep the data which has "now.AddDays(-1).ToString(“d-mmm-yy”)” in Date



image image

Hi,
Try LINQ:

DTCase.AsEnumerable.Where(Function(r) If(DateTime.TryParseExact(r("Date"),"d-mmmm-yy",System.Globalization.CultureInfo.InvariantCulture),DateTime.ParseExact(r("Date"),"d-mmmm-yy",System.Globalization.CultureInfo.InvariantCulture) = now.AddDays(-1).ToString("d-mmmm-yy"), False)).ToArray
1 Like

Hi @prititit,

Sample date : Apr 5, 2020
Value = now.AddDays(-1).ToString(“MMM d, yyyy”)

Sample date : Apr 05, 2020
Value = now.AddDays(-1).ToString(“MMM dd, yyyy”)

1 Like

I would suggest changing the operation to greater than or less than
First condition to use

“Date” is greater than value Now.AddDays(-2)
OR
“Date” is less than value Now

Hello @Shraddha_Gore

What if I want to get the data after last 2 days.

April 13,14,15

I tried this but its not working

image

Use the >= operator
Or AddDays(-3)

Hi @Adrian_Star

I’ve tried it. But still not working :frowning:

As pointed out by @Pravin_Patil1 & @Adrian_Star , you’ll have to manipulate AddDays() or filter operator.

Ok, then try my LINQ.
Customize it according to your needs

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.