How to convert date format extracted in pdf in uipath

Hi,

In my PDF, i will have a transaction date, sometimes it is displayed in this format dd/m/yyyy (e.g 14/7/2021 and sometimes it is displayed in this format dd/mm/yyyy (e.g. 14/07/2021). So when i have 14/7/2021 in the pdf is it possible to change it to 14/07/2021 using uipath

thank you

Hi,

Can you try the following?

Regex.Replace

System.Text.RegularExpressions.Regex.Replace(yourString,"(?<=\d+/)(?=\d/\d+)","0")

DateTime.ParseExact

DateTime.ParseExact(yourString,"dd/M/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

In DateTime.ParseExact case, yourString should not contains extra characters except date.

Regards,

@anonymous3 - Alternation solution…

system.text.RegularExpressions.Regex.replace("14/7/2021","(?<=\d{1,2}/)\b(\d)\b","0$1")

how can I use regex.replace if I want to change my format from d/mm/yyyy to dd/mm/yyyy

Hi,

how can I use regex.replace if I want to change my format from d/mm/yyyy to dd/mm/yyyy

The following will work.

System.Text.RegularExpressions.Regex.Replace(yourString,"(?<=^|\D)(?=\d/\d{1,2}/\d{2,4})","0")

FYI, it can be converted for day and month with single expression, if use DateTime.ParseExact as the following.

DateTime.ParseExact(yourString,"d/M/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Regards,

thank you very much

Mark this as solved if above solution solved your issue.

please watch this video to learn more about the data manipulation and date formatting.
Link: UiPath | Date Formatting | Convert date to String | Get date format | yyyy.MM.dd | dd.MM.yyyy - YouTube

Best regards
Mahmoud

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