Filter Date column in csv file

Hi

I have a csv file which has the date column. The column is in General format. And the date format is in MM/DD/YYYY with some time. Ex. 10/25/2019 11:21:00 AM. I want to delete the records which are older than last 2.5 months.

First i am finding the fromDate. FromDate = DateTime.Now.AddDays(-76).

Then I am filtering the data table with Assign activity.

dt_irc1 = dt_irc1.Select(“Requested >”+"’"+fromDate.ToString+"’").CopyToDataTable

Requested is the column name. But its giving wrong output. Its also fetching older data than last 76 days.

Hi @kkpatel,

Consider using Filter Data Table activity, more info here: https://docs.uipath.com/activities/docs/filter-data-table

Regards.

Hi @kkpatel,

try following code

dt_irc1.Select("[Requested] >= '#"+fromDate.ToString+"#'").CopyToDataTable

Hi,

Can you try the following?

 dt_irc1 = dt_irc1.AsEnumerable.Where(function(r) DateTime.ParseExact(r("Requested").toString,"MM/dd/yyyy hh:mm:ss tt",nothing)>Today.AddDays(-76)).CopyToDataTable

`
(In case of your hour format is “hh”)

or

 dt_irc1 = dt_irc1.AsEnumerable.Where(function(r) DateTime.ParseExact(r("Requested").toString,"MM/dd/yyyy h:mm:ss tt",nothing)>Today.AddDays(-76)).CopyToDataTable

(In case of your hour format is “h”)

Regards,

I am getting error here that String was not recognized as a valid date time format.

Hi All

I am attaching the exact file. Could you please help me to filter out the dates older to 2.5 months (76 days).Sample.xlsx (10.7 KB)

Hi,

Hope this helps you.

Sample20200108-2.zip (21.8 KB)

Regards,

1 Like

Thank you so much @Yoichi. Its working and giving me correct result.

2 Likes

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