Date not extracted corretly in data labeling

Hello all,
I want to extract this date from pdf , and i am using data labeling , when i select it it gives me the string that i did nit need
when i declared it as date , in ml extractor there is error and in data labeling display(2022-01-22
thank you for help

image

Hi @nora_ziani,

Did you convert from string to datetime right?

like: DateTime.ParseExact(dateStr,“dd-MMM-yy”,System.Globalization.CultureInfo.InvariantCulture)

I must get it as String in data labeling and machine extractor
after that i must convert it and disp?

@nora_ziani

If you get it as string in this format 31-JAN-22 it is better to convert string to date after.

1 Like

my problem i want to add also the hour 05:00
2022-04-26T10:00:00 like this as example

@nora_ziani

So your extracted string looks like 31-JAN-22 05:12? Or you have to extract seperately?

1 Like

2022-04-26T10:00:00 like this

@nora_ziani

First
Assign
ExtractedString = extractedString.Replace(“T”, “ “)

Second
Assign
ExtractedDatetime as Datetime = datetime.ParseExact(extractedString, (“yyyy-MM-dd HH:mm:ss”, system.Globalization.Cultureinfo.InvariantCulture)

1 Like

Hi! @nora_ziani,

Follow the steps to achieve your requirement!

  1. Read the pdf using read pdf activity store it in a variable.
  2. Use the regular expression to get the date.
  3. Make sure You have imported the namespaces System.Text.RegularExpressions from the Import pannel.
System.Text.RegularExpressions.Regex.Match(PDFOutput,"(?<=From:).*(?= )").ToString

Reference:

Regards,
NaNi