Deleting a row from excel on a date based condittion

Hi guys,

Let me explain it real quick.

I have an excel document. There is a column named " Created Date ". its formatted to dd.mm.yyyy hh:mm:ss , so its like " 28.02.2020 15:17:32 ".

I want to delete the rows where the date difference between todays date is lower than 15 days old.

so today is 10.03.2020 i dont want to see 01.03.2020 because the difference is lower than 15.

I want to make it in filter datatable activity. I did converted the file in to a DT.

How can I do it.
Thanks .

1 Like

@berkaykor in value give:
Datetime.today.adddays(-15).tostring

or
Datetime.today.adddays(-15).tostring(“dd.MM.yyyy hh:mm:ss”)

Regards

Hey shanmukh_pothamsetty

I tried both it compiles there is no error but it doesnt filter.

Hi @berkaykor

Can you share a sample excel file

Thanks

@berkaykor , it might be because when you read from Excel , the MM and date values interchanges
ex: 28-01-2020 12:00:00 in Datatable it will be 01/28/2020 12:00:00

Print the row Created date first and see in which format it is coming
Else share the excel file

Regards
Shanmukh

Since i just opened the account I cannot share it, site doesnt allow me to.

Is there any other way for me to share?

and i did print it in a message box

@berkaykor in value give this:- Datetime.today.adddays(-15).tostring(“yyyy-MM-dd hh:mm:ss”)

It will solve the issue

Regards
Shanmukh

Tried it too also didnt work but

you can download the file from here.

thanks alot guys for your efforts

@berkaykor Can you Check this workflow :
FilterByDate.zip (11.4 KB)

Check the Page 2 Sheet First, Delete that Sheet, Run the Workflow. Check the Excel File Page 2 Sheet Again. It Should be the Output you needed.

When Comparing Date Values , You cannot convert it into a String and Compare, As it is a String Comparison and not a Date Comparison. That is why you don’t get any results, or you get irrelevant results.

Hence I used a Linq Query to Find the rows which have Dates which are greater than 15 days.

Hope this is what you needed. :sweat_smile:

1 Like

Yess its working thanks alot. I understood the problem as well.

Thank you all.

2 Likes

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