Check three column value and update to another column through linq

Hello All,

I want to write linq query where i have to check "Task " column contain expires then check “date” column if date is in the range of 15 days start from today. (today is 06/11/2021 to 06/20/2021). then check in “Status” column if it is null then update “status” column to ‘present’. else remaining data are same as it is. Please help on these. I have tried to write multiple query to find result but i am not getting exact result.

Thanks!
Data.xlsx (8.7 KB)

You meant to say range is 10 days??

@pankajj - For the time being I have assumed the Range is 10 sine you mentioned between 6/11 and 6/20 I have derived the below solution…

image

Read Range - Check the Preserve Format and Save the output as dt

Assign

dt.AsEnumerable.Select(Function(r) dt.Clone.LoadDataRow({r("ID"),r("Task"),r("Date"),if(r("Task").ToString.Contains("Expires") AndAlso (Datetime.Parse(r("Date").ToString) >= Cdate(Now.tostring("M/dd/yyyy")) and Datetime.Parse(r("Date").ToString) <= Cdate(Now.AddDays(10).tostring("M/dd/yyyy")) AndAlso String.IsNullOrEmpty(r("Status").ToString)),"Present",r("Status")),r("P.no")},False)).CopyToDataTable

My Input(Purposely added Not Null in the status column to check the condition)

image

Output
image

Hope this helps…

Learned this code from @Yoichi :+1:

1 Like

@pankajj - Did you get a chance to try the above LINQ query? If yes and Satisfied your query posted above… Please mark my post as solution, that will close this thread and others will be benefited.

Above mention solution work for me . Thank you for your support