How can i convert date : (dd/MM/YYYY) to (dd/MM/YY) plz?

Hi @prasath17
may be if he hadn’t tick the preserve format range , then date would come in format as MM/dd/yyyy HH:mm:ss when used .ToString

when debugging the workflow , there is exception details section which u can check for detailed exception

2 Likes

image

seems that this may be an issue with invoke code

can u try @prasath17 code with below changes

dt.AsEnumerable().ToList().ForEach(Sub(row) row(1)=DateTime.ParseExact(row(1).ToString.Trim,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yy”))

assuming that column index of Date d’entrée is 1

also tick the preserve format option in read range

19.10.6+Branch.support-v2019.10.Sha.9162a1e5a24a523df288d8d981c0096cc394d01d

Source: Invoke code

Message: Exception has been thrown by the target of an invocation.

Exception Type: System.Reflection.TargetInvocationException

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> 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 UiPathCodeRunner_9bcb912876ca4275880f61d24c37dc1a._Lambda$__1(DataRow row)
at System.Collections.Generic.List1.ForEach(Action1 action)
at UiPathCodeRunner_9bcb912876ca4275880f61d24c37dc1a.Run(DataTable& dt)
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 inArgs, IEnumerable1 imps, Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

@Soudios - As I asked, please share the screenshot of the sheet(at least showing 10-20 rows) I would like to look at the date formats…

Same problem :


dt.AsEnumerable().ToList().ForEach(Sub(row) row(1)=DateTime.ParseExact(row(1).ToString.Trim,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yy”))

Test_uipath.xlsx (8.7 KB)

Hi @Soudios

when u debug can u show the exception details in local panel
image

1 Like

@Soudios - I see your format is M/d/yyyy..but in your query you asked for dd/MM/yyyy

image

Not sure, why the requirement has changed???

1 Like

it is different for me to it is in dd-MM-yyyy
image

1 Like

I don’t see that

image

@Soudios - You changed your sheet…I downloaded when you attached initially…that is what i saw…

1 Like

Hi @Soudios
check this
Main.xaml (8.4 KB)

Regards,
Nived N
Happy Automation

2 Likes

Yes i just added something in column C

Hi @Soudios
just check the xaml file i send it seems to be working fine

1 Like

@NIVED_NAMBIAR
The result :
image

i got the correct requirement
image

Please check the input file with my workflow

1 Like

Not working, i think because i am using an old excel

It seems that i am also using same excel version too

1 Like

No i am using excel 2010, to send you the draft i sent u from a other excel version