Error when Converting String to Date format in data table

Assign activities:

dateString = row.item(“Date”).ToString

dateStringconverted = DateTime.ParseExact(dateString,“dd/MM/yyyy”,system.Globalization.CultureInfo.InvariantCulture)

resulted in error :RemoteException wrapping System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Please help

Thank you!

Hey can you display this in logs and see whats the value

row.item(“Date”).ToString

@Shawn11

This format that you give in parseexact should exactly match with the input format you are providing…

So this needs to be correct - dd/MM/yyyy

And if you are reading data from excel generally display value and backend value might be different…to know the exact format check the data in datatable from locals panel or use a log message and log the date and check and then use exact format

Rather system dateformat or general formats can be converted using Cdate(value) - here we needed not specify the format …

Hope this helps

Cheers

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