Date conversion error

Hi All,

i have an excel sheet in which date is of format “02-03-2020” and the application accepts it as “03-02-2020”. Can anyone support in conversion?
i tried using below format but it is throwing an error.

i checked out in the debug mode…it is coming as “02-March-20”

Assuming “02-03-2020” is in variable startdate in format dd-MM-yyyy as a string, do the following:

Set MyNewDate = Datetime.ParseExact(startdate, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MM-dd-yyyy"), where MyNewDate is a string in format MM-dd-yyyy.

@som17 Can you Show us the Value of Date in a Message Box after reading the Excel Sheet?

startTime: 02-Mar-20


it came as
startTime: 02-Mar-20

@som17 Then I guess you need to use this Expression:

Datetime.ParseExact(startdate, “dd-MMM-yy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-dd-yyyy”)

1 Like

thanks…it worked…:slight_smile:

1 Like


I tried to pass this expression into TyPeInto but i got below 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)

Typeinto: Datetime.ParseExact(startdate,“d-MMM-yy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-dd-yyyy”)+" "+startTime
whre start time is the time fetched from excel

data fetched from excel is:

Going to schedule job with following criteria
Request Name :Program - Automatic Posting
Frequency :2 HRS
Start Date :2-Mar-20End Date :5-Mar-20
Start Time :7:30End Time :7:30

@som17 Can you Send a Screenshot of the Error?


@Lahiru.Fernando can u please help in the above issue

@som17 Can you please check the Expression that I have suggested , it was small ‘d’ and it should be ‘dd’ :sweat_smile: