Sort from a date

Hello guys, I have an excel in this format

C1 C2 C3
x y 21/03/2019
z x 19/09/2020
y x 07/10/2020
x z 11/11/2019

I want to create a datatable with only the row with C3 from 01/01/2020 onwards. Can you help me? Thanks in advance!

Hy @a.calabro, welcome to the UiPath Community.

Working with dates can be a bit tricky because of formatting.

One simple solution would be to create a helper column with the date number.
Copy the date to another column and then format it: “Format Cells: => General”. You will se a number.

First use a ‘Read Range’ activity to load your data table
Use this number to sort your data using the ‘DataTable Sort’ Activity

Regards

1 Like

I can’t edit the excel file, that’s the problem… any other advice?

Hi @a.calabro, I would suggest the following steps:

  1. read range activity to load the excel-file to a datatable
  2. now it depends on the exact format of the date in the datatable. If it is already a datetime datatype, you can use filter and sort activities for your datatable.
    If the cells are in another format you should use parse or parseexact to convert it to a datetime datatype. a new column in your datatable will be usefull. I used this post to help me with converting string to date: Guidance on String/DateTime Conversion and String Manipulation
  3. now you should have yout datatable as you needed.

Regards
Moritz

1 Like

Hy,

Please check my attached workflow, you can convert the date to number using vb
CInt(MyDate.ToOADate), in a new column in the data table. You use this formula to convert your query date and use an ‘Filter DataTable activity’
Please have a look at my workflow

Regards

SortDate.zip (29.7 KB)

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