kkpatel
(Kamal)
January 8, 2020, 8:28am
1
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.
YAZIDI
(YAZIDI Abdelhadi)
January 8, 2020, 8:33am
2
Hi @kkpatel ,
Consider using Filter Data Table activity, more info here: https://docs.uipath.com/activities/docs/filter-data-table
Regards.
samir
(Samir Mohite)
January 8, 2020, 8:39am
3
Hi @kkpatel ,
try following code
dt_irc1.Select("[Requested] >= '#"+fromDate.ToString+"#'").CopyToDataTable
Yoichi
(Yoichi)
January 8, 2020, 8:45am
4
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,
kkpatel
(Kamal)
January 8, 2020, 11:25am
5
I am getting error here that String was not recognized as a valid date time format.
kkpatel
(Kamal)
January 8, 2020, 11:31am
6
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)
Yoichi
(Yoichi)
January 8, 2020, 2:06pm
7
Hi,
Hope this helps you.
Sample20200108-2.zip (21.8 KB)
Regards,
1 Like
kkpatel
(Kamal)
January 8, 2020, 2:31pm
8
Thank you so much @Yoichi . Its working and giving me correct result.
2 Likes
system
(system)
Closed
January 11, 2020, 2:32pm
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.