How to remove future Dates

Hi Team,

I want to remove future dates in excel with one condition…I am able to remove the future dates but condition is : say for example today is aug 29 2022 i need to keep tommorow’s date also which is Aug 30 2022 so keeping the current date and the next date need to remove all the future dates…hope u got my point…

I am able to remove the future dates with above expression but i am unable to find a logic for the above condition…

Hi @bhanupriya.cb

How about this expression ?

Dt_Read.AsEnumerable.Where(Function(x)Not(String.IsNullOrWhiteSpace(x("ColumnName").ToString)) AndAlso ((CDate(x("ColumnName").ToString).Year >= Now.Year) AndAlso (CDate(x("ColumnName").ToString).Month>(Now.Month)))).ToArray.copytodatatable

Regards
Gokul

Hi @bhanupriya.cb ,

Could you maybe Check the below Expression :

Sheet3DT.AsEnumerable.Where(Function(r)(Date.ParseExact(r("ActualLWD").ToString,"dd-MMM-yy",System.Globalization.CultureInfo.InvariantCulture).Date = Today.AddDays(1).Date) orElse Not(Date.ParseExact(r("ActualLWD").ToString,"dd-MMM-yy",System.Globalization.CultureInfo.InvariantCulture).Date>Today.Date)).CopyToDatatable

we just specify the needed date frame for today and tomorrow

(From d in dtData.AsEnumerable
Let dp = DateTime.ParseExact(ColName).ToString, "dd-MMM-yy" ........)
Where dp.Date >= Now.Date And dp.Date <= Now.AddDays(1).Date
Select r = d).CopyToDataTable

Thank you all for quick response…:slight_smile:

1 Like

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