User Enrollment Date (mm/dd/yyyy) | Name | Phone Number
08/16/2018 Test 1 555
09/06/2018 Test 2 555
10/07/2019 Test 3 555
10/16/2019 Test 4 555
How can I filter the entire data table and remove rows based off the enrollment Date being greater or equal to Sept 04, 2018 (09/04/2018) and less than or equal to the current day - 7, in this case (10/07/2019).
In this example I would want to remove Row 1 and Row 4. I have tried using the filter datatable activity but am struggling to do so.
Use Datatable.Select(“[Enrollment Date]>=‘09/04/2018’ and [Enrollment Date]<=Now.AddDays(-7).ToString(“mm/dd/yyyy”)”.CopyToDatatable()
use remove data row activity and pass the value
Otherwise, if it is converting only some of the dates incorrectly and the cultureinfo doesn’t fix it, you will have to edit the CSV before reading as a datatable. Read it as text, change the date to a more specific format such (instead of 22-12-2019 change it to December 22 2019 as an example), then read as datatable. If it brings it in as a string, then use Datetime.ParseExact to change the string into a datetime.
That is how you convert the string “09/04/2018” into a datetime variable, yes. However, you want to ensure that the CSV file is being read by uipath as datetime variables, and that the datetime coming in is in the correct format.
To check if it is coming in as a datetime, read the CSV to a datatable variable, then in a write line activity put: YourDataTable.Columns("YourColumnName").DataType.ToString
This will tell you if it is reading it as system.datetime or system.string
If it is string, then you will need to create a new column as type datetime, loop through each row and use datetime.parseexact to assign the newly created column as a datetime (parsed from the old date column). Then delete the column and rename your column to the old ColumnName if you choose.
Now you have a datetime column and you can prepare the filter as specified above. Be sure to include the number sign (#) before the date in your Select statement which signifies that you are comparing a datetime value.
If the datetime is getting converted in the wrong format, try the actions that I mentioned in my above comment to alter the cultureinfo before reading the CSV, or if that doesn’t work then alter the CSV directly before reading it in as a datatable.