How to convert (1. Marz 2024) into SAP date format (1/3/2024)?

In UiPath Studio, I would like to convert the ‘Date’ value (1. Marz 2024) captured in sample-invoice.pdf into SAP date format (1/3/2024). The method I used to capture the PDF file is the following code: System.Text.RegularExpressions.Regex.Match(pdfText, "\d{1,2}\.\s\w+\s\d{4}").Value. Does anyone know how to convert it into SAP date format (1/3/2024)?

Hi,

Can you try the following expression?

DateTime.ParseExact(yourString,"(d. MMMM yyyy)",New System.Globalization.CultureInfo("de_De")).ToString("(d/M/yyyy)")

Regards,

1 Like

Hello @Yew_Mun_Lam_IVC ,

Some clarifications before giving you the answer:

  • I notice on your Locals pane, that the value is in german, and therefore instead of 1. Marz 2024, the bot is properly reading 1. März 2024

Taking that into consideration, I will split the steps in 2 to make it easier, but could be done in a single assign.

1- Convert that string into a datetime variable

  • Datetime.ParseExact("1. März 2024","d. MMMM yyyy",new System.Globalization.CultureInfo("de-DE"))
  • This does return your text formatted as datetime

2- Convert your datetime variable to whatever format you prefer:
date_myVariable.ToString(“d/M/yyyy”)

image

Hope this helps!

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