cancel
Showing results for 
Search instead for 
Did you mean: 

Date Extraction from string

BhargavaM_R
Level 3
Hi,

Please suggest ways to extract date in the mm/dd/yyyy format from below given strings

10/15/2022, 23:59:59 CEST
10/15/2022, 23:59:59
10/15/2022, 23:59
All the above 3 strings are of mm/dd/yyyy format

Below dates are of format dd.mm.yyyy
20.10.2022, 21:59:59 CEST
20.10.2022, 21:59:59
20.10.2022, 21:59

both the formats given, need to be converted to mm/dd/yyyy and only date needs to be extracted.

I have tried using Utility - Strings - Regex::Replace with patter "(\d{1,2})\.(\d{1,2})\.(\d{4})" and replacement "$2/$1/$3" but this does not help with the alphabets and slashes in the string. 


------------------------------
Bhargava M R RPA Engineer
Associate Software Engineer
Mphasis
Asia/Kolkata
------------------------------
2 REPLIES 2

Hi @Bhargava M R,

The regular expression you provided only handles period (.) character but not forward slashes (/), hence I modified it a bit as shown below:
(?<Date>(\d{1,2})[\.\/]+(\d{1,2})[\.\/]+(\d{4}))​


Test Result On Regex101:

19378.png

To test the same, you can use either of the below two approaches apart from replace regex action as shown below:

Approach 1:

You can use the ​'Extract Regex All Matches' action from the latest 'Utility - Strings' VBO at Digital Exchange and use the following regex expression:


Test Result On Object Studio:


19379.png
19380.png

Approach 2:

You can use the original action 'Extract Regex Matches' which is present from the prior versions of this VBO and make sure you pass the named values collection with the following schema:

19381.png
The name values collection should have two columns called as, 'Name' and 'Value' with one row where the 'Name' column cell has the value as Date.

The regular expression pattern would be same as above and upon executing the action you should be able to get the result in the same collection as follows:
19382.png

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------

---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Thank you @devneetmohanty07​​

------------------------------
Bhargava M R RPA Engineer
Associate Software Engineer
Mphasis
Asia/Kolkata
------------------------------