How to fetch records from a excel sheet of a whole month

Currently I have this query in which

dateColumnName - Is the variable in which i am storing the column where date is appearing
date1 - contains Tomorrow’s date

The Query :

dt.AsEnumerable.Where(Function(row) CDate(row(dateColumnName).ToString).Date.ToString(“dd-MM-yyyy”).Contains(date1) andAlso Not(row(12).ToString.Trim.Equals(“Cancelled”))).CopyToDataTable

Now this query fetches me the record for the required date which is 18th May

Now what I want to do is at every end on the month it should fetch the records of the whole next month

Like today is 17th May, Once it is 31st May. It should fetch me the records of the whole june month,

Once it’s 30th June it should give me the records of the whole July month

Once it’s 31st july it should give me the records of the whole august month

Any help is appreciated

Hello @Ishan_Shelke1 ,

I think the query which Yoichi mentioned in the below post can help you solve your requirement. but need some modification.

Instead of Today.Year and Today.Month you will have to replace the data which you have.

do this

image

if
now.Day = new datetime(now.year, now.AddMonths(1).Month, 1).AddDays(-1).Day

then assign
dtWholeNextMonth = dt.AsEnumerable.where(function(row) cdate(row("Column1").ToString).Month = now.AddMonths(1).Month).CopyToDataTable

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