cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to filter a folder by dates Blue Prism

I am having issues around [Utility - Collection Manipulation - Filter Collection] I have a Get Files action which gets all the files from a particular folder and outputs them into a collection in Blue Prism (there are 14 .txt files) I then use the Filter Collection Object to filter this folder "Files" I am trying to only bring back results in the collection for where the "Created" (DateTime) = today or yesterdays date.

Date1( DateTime) FormatDateTime(Today()&" "&LocalTime(),"dd/MM/yyyy") Date2(DateTime) FormatDateTime(DateAdd("9", "-2", Today())&" "&LocalTime(),"dd/MM/yyyy")

Filter Expression : "[Created] <= "&"'" &[Date1]&"' and [Created] >= "&"'" &[Date2]&"'"

There is no Error message and it doesn't output any results. I am thinking that maybe Date1 and Date2 aren't being read as dates perhaps?

Any help on this matter would be greatly appreciated.

Regards,

Gary

--------------------------------------------------
Disclaimer: This content was auto-posted from Stackoverflow. The original Stackoverflow question is here Stackoverflow Post, posted by Gary.
Hi  I am a Digital Worker. Please check out my profile to learn more about what I do!
3 REPLIES 3

John__Carter
Staff
Staff
Try using # around the dates. This page (despite being about c-sharp) will give you the idea​​ https://www.csharp-examples.net/dataview-rowfilter/

------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

Hi, 

I tried it and when I create Text data items (DateFrom, DateTo) it works when I created them as DateTime it did not work.

"Created>'"&[DateFrom]&"' AND Created<'"&[DateTo]&"'"

The format of the data items must be, of course, MM/dd/yyyy or dd/MM/yyyy depending on your windows settings.

What I don't understand is the following Date1( DateTime) FormatDateTime(Today()&" "&LocalTime(),"dd/MM/yyyy") Date2(DateTime) FormatDateTime(DateAdd("9", "-2", Today())&" "&LocalTime(),"dd/MM/yyyy"). In here you are creating DateTime data item but then you format it to the string to certain format. That is unnecessary.

Regards,


------------------------------
Zdeněk Kabátek
Head of Professional Services
NEOOPS
http://www.neoops.com/
Europe/Prague
------------------------------

PvD_SE
Level 12
You could sort the collection on the date, read the collection in a loop and check each row for the creation date to see if it needs processing or not. It is after all only 14 rows. That'll save you filtering the collection.

In order to tackle a issues with syntax such as in a Filter action, start simple by using only one date to select on and then work your way up to multiple dates when this works.

To keep thing readable, use a Data item (eg. [Filter], Text) that you build up in a MultiCalc stage and use in your Filter action. First you calculate Date1, then Date2 and then you build the Filter. That way you can easily see if you missed a quote or bracket in your calculations.

This: FormatDateTime(Today()&" "&LocalTime(),"dd/MM/yyyy")
Delivers this: 30/11/2020
Note there's no time!

This: FormatDateTime(Today(),"dd/MM/yyyy") &" "&LocalTime()
Delivers this: 30/11/2020 11:45
Which might be what you're looking for. This: FormatDateTime(Today()&" "&LocalTime(),"dd/MM/yyyy hh:mm") does the same.

Don't forget to let us know how it went!

------------------------------
Happy coding!
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)