Finding a date in string (text spanish date)

Hello, I have an excel document to which I must copy the date that has combined with another text, extract the date that comes in Spanish format:
"CORREDORES PERSONA NATURAL MOROSOS AL 20 DE JUNIO DE 2019
I only need the date without the “DE” between each word “DE”

that is to say that it looks like this:
20 JUNIO 2019

to be able to use it as datetime and then use the dates, It is important to mention that dates are dynamic, change date, but keep the same structure

Now do the following: extract the text as a variable but I can not perform a regex to extract the date that is in the following format, DateTime.now.toString (dd MMMM yyyy). The problem is that when using REGEX, I can not identify the correct structure to extract the date, and try to:
^ ([0-2] [0-9] | (3) [0-1]) (\ /) (((0) [0-9]) | ((1) [0-2])) ( \ /) \ d {4} $

(? n: ^ (? = \ d) ((? (0? [13578]) | 1 [02] | (0? [469] | 11) (?!. 31) | 0? 2 ( ? (.29) (? =. 29. ((1 [6-9] | [2-9] \ d) (0 [48] | [2468] [048] | [13579] [26]) | ( 16 | [2468] [048] | [3579] [26]) 00)) | (?!. 3 [01]))) (? [-. /]) (? 0? [ 1-9] | [12] \ d | 3 [01]) \ k (? (1 [6-9] | [2-9] \ d) \ d {2}) (? (? = \ x20 \ d) \ x20 | $))? (? ((0? [1-9] | 1 [012]) (: [0-5] \ d) {0.2} (? i: \ x20 [AP] M)) | ([01] \ d | 2 [0-3]) (: [0-5] \ d) {1,2})? $)

Anyone have any ideas ?, Since I can divide the roof with the split, and just leave it like this: 20 JUNIO 2019

Update 25/6719
Captura2 I could solve it, before they answered me but I think that is exactly what you answered me, what I did was the following:
use activity-> Split String
in the Input place “the variable”, in the Result “the output variable” then with the Assing activity, place "the variable that leaves the RESULT of the split example:
variable (5) + variable (7) + variable (9),
so that in the “assign” I threw the data 20JUNIO2019 ← but now I have those as a STRING, but I want to convert it to DATETIME, I’m trying but I can not convert it, I get error error,Capture3
I am using this sentence:

NewValueDateString = Convert.ToDateTime (“”) (“ddMMMMyyyy”). ToString) .Date
DateTime.ParseExact (convertedDate.ToString (“dd / mm / yy”), “dd / mm / yy”, Nothing) .ToString (“MM / dd / yyyy”).

you will know if you can help me, convert the string 20JUNIO2019 → DateTime

Of course, taking into account that the string 20JUNIO2019, the date changes since the name is dynamic, but always keep the structure ddMMMMyyyy

Now I need to convert in dd-mm-yyyy example: 06-20-2019

1 Like

Hi @jonathanp90
Is this format always the same or dynamically generated if it is statically you can use string manipulation for that See link below for your reference.
String Manipulation

2 Likes

in all documents is de Same, for example:

20 DE JUNIO DE 2019
30 DE JULIO DE 2019
1 DE AGOSTO DE 2019
2 DE AGOSTO DE 2019

Is de samen estructure but the date change in relation to the day when you export the Excel file @pattyricarte

1 Like

Hi @jonathanp90
Oh its great i can give some logic.First you need to get the string that you want.
For example if you get this string “20 DE JUNIO DE 2019”
then use indexof to get the position of “DE” and use the remove to remove the word “DE”

I hope it make sense! :smiley:

2 Likes

@jonathanp90 well as above one of our said just try to store the string in a variable once you stored it you can use split function say the variable name of string is outtext. Then use assign activity and in place value give like this outtext. Split(“DE”. To chararray). It gives you out put as array of string. Then store it in a variable place say strarray. Now to get your requirement use one more assign activity and in place value give like this strarray(0)+" “+strarray(2)+” "+strarray(4) and store it to a variable it gives you output as per your requirement. Hope it helps to you

1 Like

@jonathanp90 Use regular expression to get
Value 20 DE JUNIO DE 2019 than replace DE with null

Regular expression Link

Captura2 I could solve it, before they answered me but I think that is exactly what you answered me, what I did was the following:
use activity-> Split String
in the Input place “the variable”, in the Result “the output variable” then with the Assing activity, place "the variable that leaves the RESULT of the split example:
variable (5) + variable (7) + variable (9),
so that in the “assign” I threw the data 20JUNIO2019 ← but now I have those as a STRING, but I want to convert it to DATETIME, I’m trying but I can not convert it, I get error error,Capture3
I am using this sentence:

NewValueDateString = Convert.ToDateTime (“”) (“ddMMMMyyyy”). ToString) .Date
DateTime.ParseExact (convertedDate.ToString (“dd / mm / yy”), “dd / mm / yy”, Nothing) .ToString (“MM / dd / yyyy”).

you will know if you can help me, convert the string 20JUNIO2019 → DateTime

Of course, taking into account that the string 20JUNIO2019, the date changes since the name is dynamic, but always keep the structure ddMMMMyyyy

Now I need to convert in dd-mm-yyyy example: 06-20-2019

@jonathanp90 once you get the date as string give like this buddy in assign activity
DateTime.ParseExact(strdate.ToString,“ddMMMMyyyy”,system.Globalization.CultureInfo.InvariantCulture) you will get the output as you required.

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.