24-06-22 03:18 AM
Answered! Go to Answer.
24-06-22 02:22 PM
|
|
"(\d+)\w{2}\s(\w+)\s(\d{4})"
"$2 $1, $3"
March 18, 2022
😞24-06-22 08:37 AM
Hi Dhenn,
For your requirement you can create a new business object called as 'Date Time Manipulation (Advanced)'. Provide the below Name Space Imports and External References in the Page Description stage of your Initialise action keeping your language set up as 'Visual Basic' as shown below:
Now you can create a new action called as 'Parse Date'. This action will have two input arguments:
1) Input Date (Text): This is the required date string from where you want to generate a valid date data item.
2) Date Formats (Collection): This collection will have one column called as 'Date Format' which will comprise of all the possible date formats in each row which your input date string can have:
Also, create two output arguments:
1) Output Date (Date): This is the output date that will be generated from this given action.
2) Message (Text) : This will have the error message in case of any exception.
Now add a code stage named 'Parse Date' as shown in the workflow and map the arguments as below and provide the same code as well:
Dim temp_message As String
For Each format_item As DataRow In Date_Formats.Rows
Try
Output_Date = DateTime.ParseExact(Input_Date, format_item(0).ToString, System.Globalization.CultureInfo.InvariantCulture).Date
Message = "Success"
Exit For
Catch Ex As Exception
temp_message = format_item(0).ToString & " - " & ex.Message.ToString
If Message.Equals("") Then
Message = temp_message
Else
Message = Message & Environment.NewLine & temp_message
End If
Continue For
End Try
Next
That's all and you are set now to publish this action and make the call from Process Studio.
Test Scenario:
Just make sure you pass the input date in the following format to this action: 12 March 2022
So, if you input text has any date as 12th March 2022, ensure you remove the 'th', 'st' or the 'nd' portion first from your input string.
Before this action you can simply call a calculation stage and do this operation with the following expression:
Replace([Input Date],Mid([Input Date],1,InStr([Input Date], " ")-1),Replace(Replace(Replace(Mid([Input Date],1,InStr([Input Date], " ")-1),"th",""),"nd",""),"st",""))
Once you have the input in a format which can either be: dd MMMM yyyyy or d MMMM yyyy
dd MMMM yyyy
will be used for any date which can have two digits in the day place like 12 August 2022, 21 March 2022 etc.d MMMM yyyy
will be used for any date which can have one digit in the day place like 1 January 2022, 9 December 2022 etc.
Simply create a collection called as Date Formats with both these values:
So now in the action, you simply pass the input date that we got from the calculation stage along with the date formats collection and you would get your output as shown below:
24-06-22 02:22 PM
|
|
"(\d+)\w{2}\s(\w+)\s(\d{4})"
"$2 $1, $3"
March 18, 2022
😞27-06-22 01:55 AM
27-06-22 01:32 PM