Is there a way to filter a folder by dates Blue Prism
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-11-20 09:00 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-11-20 02:15 PM
------------------------------
John Carter
Professional Services
Blue Prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-11-20 02:43 PM
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
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-20 10:50 AM
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
------------------------------
Paul, Sweden
(By all means, do not mark this as the best answer!)
