String was not recognized as a valid DateTime - Why this error is coming suddenly?

The “String was not recognized as a valid DateTime” error has unexpectedly emerged.
It has been functioning correctly for the past three months, but now this error has surfaced.
I have verified that the input format remains unchanged from before.

Kindly assist me in resolving this issue.

I have used - Datetime.ParseExact(CurrentRow(“Posting Date”).ToString,“dd-MM-yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“ddMMyyyy”)

Hi,

If input string is not 01-12-2023 but 1-12-2023, can you try the following expression?

Datetime.ParseExact(CurrentRow("Posting Date").ToString,"d-M-yyyy",system.Globalization.CultureInfo.InvariantCulture).ToString("ddMMyyyy")

Regards,

@Ajinya_jorwekar

can you try this once

Datetime.ParseExact(CurrentRow("Posting Date").ToString,{"dd-MM-yyyy","dd/MM/yyyy","d-M-yyyy","dd-MM-yyyy hh:mm:ss},system.Globalization.CultureInfo.InvariantCulture).ToString("ddMMyyyy")
1 Like

Hi

Try first parsing to format:
ddMMMyyyy

Then to:
ddMMyyyy

Cheers

Steve

set a breakpoint before the type into
debug and get paused
use the immediate panel and inspect the CurrentRow(“Posting Date”).ToString Value

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Also you can directly prototype the possible corrective statements within immediate panel

For analysis statements to find all invalid, out for expected format dates have a look here:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

It gives an Error

@Ajinya_jorwekar

Datetime.ParseExact(CurrentRow("Posting Date").ToString,{"dd-MM-yyyy","dd/MM/yyyy","d-M-yyyy","dd-MM-yyyy hh:mm:ss"},system.Globalization.CultureInfo.InvariantCulture).ToString("ddMMyyyy")

sorry my bad can you us this

@Shiva_Nikhil

My Input Is Posting Date

Still Error is Coming

As mentioned in the FirstAid

This is the reason why we check on the data table level

1 Like

@Ajinya_jorwekar

please type the expression manually dont copy and paste it

Not solved yet, Still same Error

When working format array, the method signature is to meet

e.g.

taken from: FirstAid

Try this:

Step 1: capture the current row to a string variable called ‘yourstr’

Left assign:
yourStr

Right assign:
DateTime.ParseExact(CurrentRow(“Posting Date”).ToString,“dd-MM-yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“ddMMMyyyy”)

Step 2: convert to your desired format

Left assign:
yourStr

Right assign:
Datetime.ParseExact(yourStr,“ddMMMyyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“ddMMyyyy”)

Hopefully this helps

Cheers

Steve

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.