I get the error in assign activity date and time error

I get the error in the assign activity when i try to store the date and time i attach the screenshot bellow u check
I get error like this 20.4.3

Source: Assign

Message: String was not recognized as a valid DateTime.

Exception Type: System.FormatException

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 me

Hi @Chethan_P

Can you try the below statement :-

DateTime.ParseExact(CDate(item.Headers("Date")).ToString("MM/dd/yyyy HH:mm:ss"),"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyyMMdd_HHmmss")

Before implementing just have a look to the Date formats those are correct or not as per your requirement
If Yes then you can implement to go further
If No then make changes in the format as per your requirement

Hope this will solve your query

Mark as solution and like it if it helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Chethan_P

Check below

Mark as solution if this helps

Thanks

1 Like

hello i get solution from you thank you and i need one more information if i save the folder name as from address for that what should i do for an example if from by Chethan_p@stskproperties.com i want to save my folder chethan_p and date and time what should i do would you pleasae help me for that

hey some times its work after that i get error like this
20.4.3

Source: Assign

Message: Conversion from string "Thu, 23 Jul 2020 06:09:37 +0000 " to type ‘Date’ is not valid.

Exception Type: System.InvalidCastException

RemoteException wrapping System.InvalidCastException: Conversion from string "Thu, 23 Jul 2020 06:09:37 +0000 " to type ‘Date’ is not valid.
at Microsoft.VisualBasic.CompilerServices.Conversions.ToDate(String Value)
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)

Hi @Chethan_P

If you are trying to extract the Name from Email then below Regex you can use :-

image

And for Date and Time the same what i told previously :-

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

Hi @Chethan_P

So the format of the input got changed thats why it has thrown the error as :-

Message: Conversion from string "Thu, 23 Jul 2020 06:09:37 +0000 " to type ‘Date’ is not valid.

To handle such error you have to pass that format within the solution i gave you already above :-

Below is the link for various Date & Time Format :-

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

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