Filter date column in datatable

Hi, need help.
I have some dates like in “sales date” column in a datatable
09/13/2021
09/14/2021
09/15/2021
09/16/2021
09/17/2021
09/20/2021
09/21/2021

I want dates which are less than or equal to 7 days from now.
In the above case it will be 16 sept and above.

So I used one assign activity like below:
NewDate = DateTime.Today.AddDays(-7).tostring(“MM/dd/yyyy”)

Then I used Filter datatable activity and tried to filter like below:
“sales date” >= NewDate.tostring

But executing above function is not giving me any result.

Can you please help?

Hi @Deepa_Madkar

You just have to parse the datetime from the Sales column and then Compare with the the date condition

DateTime.ParseExact(row("columnname ").ToString.Substring(0, 10),“MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture) >= Now.AddDays(-7)

Regards

Hi, Thank you for the solution. I tried with your code but it’s not working. Attaching the excel and xml for your reference. Can you please tell me where I am making mistake. @pravin_calvin
Thanks in advance
Example.xlsx (6.2 KB)
Testexcel.xaml (13.1 KB)

Hi @Deepa_Madkar

Please refer to the xaml below.

Date_comparison.xaml (7.2 KB)

Hope the above helps you!

Regards

Hi @pravin_calvin
With write line it’s working.

But I want to ask how can i get only those records in excel which were displayed under output panel after write line activity was used.

Can you please suggest.

Thank you

Hi @Deepa_Madkar

You need to write in same excel file or different file.

Refer the xaml below!

Date_comparison.xaml (10.2 KB)

Regards

Hi @Deepa_Madkar

Check with the below workflow!!
Test_date.xaml (7.5 KB)

Regards
Gokul

Thank you for the help @Gokul001

But the result is showing all the data in sheet 2 which was there in sheet 1.
It is not showing records which is having sales date less than or equal to 7 days from current date

Hi @Deepa_Madkar

How about the below!

Reference xaml Below!

Date_comparison.xaml (9.2 KB)

Regards

Thank you @pravin_calvin for the help.

But on running the file, the sheet 2 is displaying all the data which was in sheet 1.

Sheet 2 should show only records with sales date having less than or equal to 7 days from current date.

Is there any way to achieve this please

Hi @Deepa_Madkar

Please refer the Post6
which has the solution provided as per your need!

Regards

Hi @Deepa_Madkar

Check with the below workflow!!
Example.xlsx (8.6 KB)
TestDate.xaml (10.7 KB)
image

Hope it will work
Regards
Gokul

Thank you so much @Gokul001
This worked.
Really thankful

Yes.
Thank you so much once again for all the help @pravin_calvin

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