How to convert string to date format("dd/MM/yyyy")

hello all,

i have a string var where i have stored one date . it is coming from pdf . But problem is in some output i am getting 20/3/2019 and some other output i am getting 203/2019 or sometime getting 2032019 . thats why i want that string as a date so that i can always get the proper date format .

please help me with some solution .

i am using few code one is

Closing_Date.substring(0,2)+“/”+ Closing_Date.substring(3,2)+“/”+ Closing_Date.substring(6,4)

but it is not working . and also i have been trying to convert it as a date but i failed .

please suggest some solution.

thanks in advance

Hi
Is the pdf having such kind of date format or the output we get from any activity been used gives such output
If it’s from pdf then fine
But if it’s from activity we can try to make that activity to get the date in right format as per the pdf and then go for conversion

@roysupriya21

thanks for your reply .

pdf date format is okay . it is 20/3/2019 but after extract and get the date the output is not similar to pdf which i have already mention above .

Did we try with activity like READ PDF or READ PDF with OCR so that the string output obtained can be manipulated with it’s string using Regex or split method

Cheers @roysupriya21

yes i have used read pdf with ocr . then use

Fine
Can I have the image of particular lint from string obtained from that pdf
@roysupriya21

here it is

No buddy
Not this
Use a writeline activity next to READ PDF and pass the string variable as input so that we can see the string there and create Regex accordingly
@roysupriya21

sorry bro . the pdf came from Client thats why i can not disclose it .

your instruction:

pass the string variable as input so that we can see the string there and create Regex accordingly

and the string out put for date is :slight_smile:
\r\n,ngsingfiate; 2502/2019\r\n

if it is helpful then please provide your idea

I got it
But can I have atleast a sample kind like one string before and after date
Like this
String1 date string2

I would like to know the string1 and string2
Cheers @roysupriya21

abc\r\nClient No: bcd\r\nRequest name: hello\r\n,ngsingfiate; 2502/2019\r\nI Pos. I Article Number I Quantity I Quantity Unit I I I\r\n010 aaa 1.00 piece\r\nRequested

one string before and after date
Like this
String1 date string2
please check above string

Hello @roysupriya21

A simple solution to this problem would be to create an Array of string Datatype variable and store all the available datetime format in your case

Arr_of_String_ = {"dd/MM/yyyy","ddM/yyyy"}

than use this code to get the desired date in string

DateTime.ParseExact(DateinStringvariable,Arr_of_strrr,Globalization.CultureInfo.CurrentUICulture.DateTimeFormat,nothing).ToString("dd-MM-yyyy")

Check this workflow and post for better understanding

Multiple Date formats.xaml (4.8 KB)

This might help you

Can you help how to convert text to date as follows
From - 2 December 2020
To - 2/Dec/2020 (dd-MMM-yyyy)