DateTime issue

Hi
I have a process that was working fine and today its throwing up an error "String not recognised as valid DateTime

File is in had Date format (which is same format as other files that have worked in past)

any ideas what I need to update?

image

Hi @KarenL

Based on the screenshot, the Assign SetDate has no problem,
since your Write Line output after that is shown in the Output Panel.

The problem happens after the out_Monday Date.

just run in Debugg and it stopped here

The column or field where you want to assign the value expects a date. Convert the output to Date first. Convert.ToDateTime(…)

Hi @KarenL,

Please check the value of your rowItem(“IssueDate”) during Debug.
Either its value is null, blank or non-date value.

Hi @KarenL

I think you should first create 2 instance variables
value1 is type GenericValue and value2 is type DateTime
As shown in the figure, you want to change the value in the datatable table to your date format.
Well, I tried a prototype and it worked, but it must be like you were looking for it

@KarenL

Try this.

      rowItem.Item("issuedDate") = Cdate(rowItem.Item("issuedDate").Tostring).Tostring("dd/MM/yyyy")

Great
So it purely because of the date format
CDate or Date.Parse might fail when it gets confused with the place where dd and MM comes and not been defined which is what

So to a valid that
Let’s try with ParseExact
—first let’s get to know the date format
Use a writeline and mention like
row(“IssuedDate”).ToString which will display us the date and it’s format based on that
If it’s dd/MM/yyyy, then

DateTime.ParseExact(row(“IssuedDate”).ToString.Substring(0,10),”dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Or
If it’s MM/dd/yyyy
Then it will be like
DateTime.ParseExact(row(“IssuedDate”).ToString.Substring(0,10),”MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Cheers @KarenL

Solve it… the date column in the input file was corrupted.
When we changed the computer time/date setting which was mm/dd/yy it allowed me to update the file to correct format

Awesome
@KarenL