Get Date range between two dates

This is my excel sheet.
I want the data from the date range between todays date and previous 6 days date. for eg : todays date= 08-06-2022 to Previous six days date: 02-06-2022.
How could i can get the data between these range date and write it in a different sheet?

DT.Select("[Date]>Now.AddDays(-6) And [Date]<DateTime.Now").Copytodatatable

1 Like

Showing these error.

Try This Buddy :slight_smile:

DT.AsEnumerable.Where(Function(r) Datetime.ParseExact(r(0).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).Day>Now.AddDays(-6).Day And Datetime.ParseExact(r(0).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).Day<=Now.Day).CopyToDataTable

Note : DT(Your Input Datatable)

Where 0 is the column index

1 Like