String is not recognized as a valid datetime

Hi Community

I cannot figure this one out.

I get the error when i try to convert at string i a have previously split and trimmed

You can see the converting assign activity gets the input: “13-02-2020” When looking in the local pane. So how is that I cannot convert it? heres how I convert:

Convert.ToDateTime(Datetime.ParseExact(newstring,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”))

Convert.ToDateTime(Datetime.ParseExact(newstring,“dd-MM-yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”))

First check your input date is in which format.

@ChrisPals

Try this. It will convert any type string date format to required string format.

         CDate("inputStrDate").Tostring("dd-MM-yyyy")
7 Likes

I get the same error event though i dont split the string

input is string format

Did you mean to convert the string to string? as shown below, in that case I recieve another error

Display the input date in message box and send the screenshot of it.

Here you go

1 Like

Not the type , display input date.

@ChrisPals I think it’s Better if you Display Like this :

“A”+newString+“B” inside the message Box

I know it’s weird but we get Confirmation of what is the real format in the String :sweat_smile:

@ChrisPals

Remove double quotes and it should be like this.

        newDateStr = CDate(newstring).Tostring("dd-MM-yyyy")
1 Like

Make sense =D

Same issue unfortunately!

@ChrisPals Then the Expression what you had used to Convert Should be Fine, Can you Tell me what you want to do actually ? I can see your Converting String to Date but again you’re converting it into String , I Did’nt Understand Why? :sweat_smile:

@ChrisPals Can you just Check if this works :
Datetime.ParseExact(newstring,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”)

This worked fine for me :sweat_smile:

1 Like

get stringdate with get text>split so I only have the date and not the time>convert to datetime.

The assign converting from newstring to the datetime variable ‘lastedit’ should be the last step.

I tried that one.

But I recieve this error:

@ChrisPals If you want it in Date Type Format , Remove .ToString(“dd-MM-yyyy”)

1 Like

@supermanPunch

ah ok! thanks alot, It works perfectly now.

Cant believe I didn’t catch that myself :sweat_smile: