String format to date

Hi,

Extracted the date from pdf, in every pdf file format is changing. In few files its like “yyyy-MM-dd or MM-dd-yyyy or dd-MM-yyyy" but need to write the extracted date in this format yyyy-MM-dd.
image
str_receive = RecieveDate
RecieveDate and str_receive are of string data type
Str_date = Datetime.ParseExact(str_receive,“yyyy-MM-dd or MM-dd-yyyy or dd-MM-yyyy",System.Globalization.CultureInfo.Invariantculture).ToString(“yyyy-MM-dd”)

Assign: String was not recognized as a valid DateTime. [Error am getting]
Tried this one but not able to extract.
Please help.

Thanks & Regards,
Lakshmi

you can use or in parse exact…use it seperately

@Lak_Ui
Str_date = Datetime.ParseExact(str_receive,“yyyy-MM-dd",System.Globalization.CultureInfo.Invariantculture).ToString(“yyyy-MM-dd”) or Datetime.ParseExact(str_receive,“dd-MM-yyyy",System.Globalization.CultureInfo.Invariantculture).ToString(“yyyy-MM-dd”)
In this way you are telling.

use TryParseExact instead this will give true or false value
Datetime.TryParseExact(str_receive,“yyyy-MM-dd",System.Globalization.CultureInfo.Invariantculture)
if true
use Datetime.ParseExact(str_receive,“yyyy-MM-dd",System.Globalization.CultureInfo.Invariantculture).ToString(“yyyy-MM-dd”) to convert

Hi!

Have a view on this thread:

Regards,
NaNi

Hi,

You can try in this way, first convert all the dates into a single format using ‘CDate’ method, then use the ‘parse extract method’ to get the required output

Regards,

Hi,
Sequence test.zip (1.4 KB)
Sample workflow i have attached, please look on it.
Op.txt (10 Bytes)

Hi,
I used Cdate to convert into date
str_1= CDate(D_format).Tostring(“yyyy-dd-MM”)
Str_date = Convert.ToDateTime(DateTime.ParseExact( str_1,"yyyy-dd-MM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-dd-yyyy”))

image
Like this i am getting i want to remove 00:00:00
How to do that.
Please help.

Thanks & Regards,
Lakshmi

Hi,

Instead of .ToString you can use .ToshortDate

Regards


Assign: Conversion from string " 23.10.2021
" to type ‘Date’ is not valid.
What changes i need to do ,getting this error, the format should be MM-dd-yyyy.
please help.

Thanks,
Lakshmi

Hi,

This (yyyy-dd-MM) might be an incorrect format,
Try with standard MM-dd-yyyy format.

Regards,

Hi @RK_0 ,


same error i am getting.

If possible, please share workflow and input file

Regards,

@RK_0 ,
I am sharing sample demo file and workflow.
Op.txt (95 Bytes)
Sequence test.xaml (10.9 KB)
Multiple pdf’s has different formats of dates but after extraction, it has to be in this MM-dd-yyyy format.
Data is extracting properly but not able to write in given format.
Please look on it.

Thanks,
Lakshmi

Hi!

Try this and let me know:

Datetime.ParseExact(InputDate.ToString, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy", New CultureInfo(“de-DE”))

Reference:

Regards,
NaNi

Hi,

I have modified the logic for most of date formats you get

If any new format follow the steps i mentioned in comment

Regards,
Sequence test.xaml (13.1 KB)

@THIRU_NANI , my extracted data is in string format,


This issue am getting.

Regards,
Lakshmi

Hey!

Can you show me the input date?

I created a logic for 20.08.2022(Dot Format)

You can refer the post which is created by @RK_0

Regards,
NaNi

@RK_0


Assign: Conversion from string " 23.10.2021
" to type ‘Date’ is not valid.

@THIRU_NANI ,
This is the input
image