I Want to Sort Date Column With a Dynamic Two dates

in my data table I want to sort this “Transaction_Date” column with two dynamic variables which are,
Start_Date=now.Date.AddDays(-7).ToString(“dd/MM/yyyy”)
End_Date=now.Date.ToString(“dd/MM/yyyy”)

output should be something like this “Start_Date<=“Transaction_Date”<=End_Date”

i want to get “transaction_dates” which only on that specific date period

Hi @Ishan_Ranasinghe ,

You would need to perform correction with the variable types and keep the type as DateTime instead of String.

Start_Date=now.Date.AddDays(-7)

End_Date=now.Date

Here, Start_Date and End_Date are DateTime type variables.

Then For Filtering, Could you check the below Expression :

DT = DT.AsEnumerable.Where(Function(x)Start_Date<=CDate(x("Transaction_Date").ToString) andAlso CDate(x("Transaction_Date").ToString)<=End_Date).CopyToDatatable

Here, DTis the Datatable variable.

For Errors on Direct CopyToDatatable, Check the below post :

1 Like

Hello @Ishan_Ranasinghe,
Refer to this xaml file, you may get some idea.
DateFilter.zip (82.8 KB)

1 Like

Thanks Gokul,solved

Thanks,Brother

1 Like