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.
Consider using Filter Data Table activity, more info here: https://docs.uipath.com/activities/docs/filter-data-table
try following code
dt_irc1.Select("[Requested] >= '#"+fromDate.ToString+"#'").CopyToDataTable
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”)
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”)
I am getting error here that String was not recognized as a valid date time format.
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)
Hope this helps you.
Sample20200108-2.zip (21.8 KB)
Thank you so much @Yoichi. Its working and giving me correct result.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.