String problem String was not recognized as a valid DateTime

this is the data that I’m getting from the orchestrator queue
image
I only need the date

this is my variable

and this is the assign activity
image

anyone know what to do?

output should be 08011963

Hi @shanti_18

Do it like this DateTime.ParseExact(in_Birthdate,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CulturalInfo.InvariantCulture).ToString(“MMddyyyy”)

Your output will be a string

cheers

image
this is the error when I try ur code

Hello @shanti_18

If you want to change the format using the activity, you can use the Modify Date activity.

Thanks

Hi @shanti_18

Can you print your in_birthdate once …and check if there are any extra spaces. If you have spaces at the ends just use in_birthdate.Trim else if there are in between date and time then include the extra spaces in the format of datetime.parseexact

Is your month coming first in your in_birthdate?? Else inter change MM and dd in the format and use dd/MM/yyyy hh:mm:ss

Cheers

@Yoichi hello sir, do you know how to solve this issue?

HI,

Can you try the following expression?

DateTime.Parse(System.Text.RegularExpressions.Regex.Match(in_birthdate,"\b\d{1,2}/\d{1,2}/\d{4}\b").Value).ToString("MMddyyyy")

OR

System.Text.RegularExpressions.Regex.Replace(in_birthdate,"^.*\b(\d{2})/(\d{2})/(\d{4})\b.*$","$1$2$3")

Regards,

“\b\d{1,2}/\d{1,2}/\d{4}\b” what is the meaning or purpose of this ?

Hi,

“\b\d{1,2}/\d{1,2}/\d{4}\b” what is the meaning or purpose of this ?

In order to extract just “08/01/1963” part.

\b means word boundary.
\d means numeric chracter and {1,2} means one or two, {4} means four characters.

So, regex pattern “\b\d{1,2}/\d{1,2}/\d{4}\b” can extract “08/01/1963”

Regards,

thank you will definitely try this

HI @shanti_18

If your in_Birthdate is a string means try like below expression

DateTime.ParseExact(in_Birthdate,{"dd/MM/yyyy hh:mm:ss","MM/dd/yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).Tostring("MMddyyyy")

If your date in the queue has different format you can add the other formats inside the {“”,“”}

Or

CDate(in_Birthdate).Tostring("MMddyyyy")

Regards
Gokul


I got the same error sir

Hi @shanti_18

Please use a log message/write line activity and write the date to your output console to check the format , and then give the format in this

DateTime.ParseExact(in_Birthdate,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CulturalInfo.InvariantCulture).ToString(“MMddyyyy”)

Change MM/dd/yyyy hh:mm:ss

Cheers

Have you tried with this expressions @shanti_18


I got the same with ur recommended code

Have you tried with this @shanti_18

image
like this one sir?

Can you share the output after extracting the data from the website. @shanti_18

image
this is the one that I need to get from orchestrator queue the output should be 03112000

Hi @shanti_18

Yes please.please send the output as a screenshot … and i beleive birthdate is what you are using in date.parseexact if not whatever that you are using print that and show the output panel

Cheers