and iwant only time value along with AM or PM. so iam using
datetime.ParseExact(read_time,“dd/MM/yyyy h:mm:ss tt”,system.Globalization.CultureInfo.InvariantCulture).ToShortTimeString but still iam not getting
where read_time is string variable
Please help me ASAP
Note: In Excel I have mentioned AM which is not visible in screenshot
And the error string was not recognized as valid date time because you are inside for each and for the 3rd row you have empty value under date column that’s y your expression is failing
Message: String was not recognized as a valid DateTime.
Exception Type: System.FormatException
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
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)
There are so many solutions above which was created for your problem and each solution by everyone works, just learn from that and see where you are getting the error and change the expression accordingly.
If you are looking for the exact solution for your requirement you can Get the solution but can never understand the expression and based on errors only you have to learn.
Can you check the expression once again and see where is the error and learn the expression
So if you want to convert a string which is representing a date and time to a different format you have to use Datetime.parseexact
“5/18/2019 8.30” - Any string with date and time format
“M/dd/yyyy h.mm” - We have to specify the format of this string “5/18/2019 8.30”
system.Globalization.CultureInfo.InvariantCulture - a parameter
ToString(“hh:mm:ss tt”) - Here i am specifying which format i want from the above string.
The output of above variable is a string variable.