I have data like this in excel
I need to retrieve records based on the MailSentDateTime Column Where Only 7 day previous records should get picked.
Resulting Excel should be :
Excel File -
Book1.xlsx (11.9 KB)
I have data like this in excel
I need to retrieve records based on the MailSentDateTime Column Where Only 7 day previous records should get picked.
Resulting Excel should be :
Excel File -
Book1.xlsx (11.9 KB)
Hi @Ishan_Shelke ,
Could you maybe check on the below Expression :
DT.AsEnumerable.Where(Function(x)CDate(x("MailSentDateTime").ToString).Date<Now.Date andAlso DateDiff(DateInterval.Day,CDate(x("MailSentDateTime").ToString).Date,Now.Date)<=7).CopyToDatatable
Let us know if this doesn’t work.
Multiple ways
"MailSendDateTime" > Now.Adddays(-7)
dt.AsEnumerable.Where(function(x) Cdate(x("MailSentDateTime").ToString) > Now.Adddays(-7)).CopyToDatatable
Hope this helps
cheers
This is only fetching the 7th day data i.e 16th March, I need all the data from the last 7 days
(From row In dtData.AsEnumerable()
Where row.Field(Of DateTime)("MailSentDateTime") = DateTime.Now.AddDays(-7)
Select row).CopyToDataTable()
This will retrieve the data from the dtData datatable where the Date column is greater than or equal to 7 days ago from today’s date. You can then use the CopyToDataTable() method to copy the filtered data to a new datatable
Regards
Gokul
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.