I am having a data table extracted from Excel that contains a column with Dates.
The current values looks like:
How can the data be filtered after the date and then by the time, so that the order is completely opposite? Or if possible, just extracting the data and inserting them into the data table in the opposite order?
then Dt.Select(â[Date]<>âNow.ToString.AddDays(-1).ToString(âdd.MM.yyyy hh:mm:ssâ)â and [Date]<>Now.ToString.ToString(âdd.MM.yyyyhh:mm:ssâ)'â).CopyToDatatable()
Do anyone have experience with filtering after date and time?
I guess that if I can make UiPath recognize the column âDateâ in my data table as first a date, and then time (something like: "dd.MM.yyy hh.mm), then it would work?
But how do i replace the existing value â03.09.2019 01:01â, so that it is not a string, but a date & time?
@Karsten_Bertelsen
Filtering on a date can be done with:
e.g. LINQ where statement
Parsing dateTime and e.g checking on String level or with second parsed compair info
just provide us a row with sample dataand the filter criteria, so we can help you on statement developing
DateTimeParsing (e.g. for UK Locals):
YourDateTimeVariable = DateTime.ParseExact( YourDateStringVariable , âYourFormatStringâ, new CultureInfo(âen-GBâ))
DateTime to String
YourDateTimeVariable.toString(âYourFormatStringâ)
Can be tried with LINQ, Keep in Mind that your data has some offset in the table, maybe you delete some rows before.
Statement: YourDataTableVar.AsEnumerable.OrderBy(Function ( r ) DateTime.ParseExact( r(0).toString , âdd.MM.yyyy HH:mmâ, new CultureInfo(âen-GBâ)).CopyToDataTable
feel free to change the cultureinfo to your needs.
Thanks for trying to help me, but I can not make it work
It works perfectly with your example, but even when I am copying your assign activity into my own sheet (and changes the variable name), it comes up with an error.
Please help me to understand your intention of what you want to achieve.
Based on my snippets filtering was working
For what reason do you use Invoke Method ImportRow?