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

image

Hi @Soudios - Please try this…

DateTime.parseexact(Row(“ColumnBName”).tostring,“dd/MM/yyyy hh:mm:ss”,system.globalization.cultureInfo.invariantculture).Tostring(“dd/MM/yy”)

if the above code doesn’t work…

you can try invoke code method…


My Input:

image

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

Hope this helps…

1 Like

@prasath17

dtSample is the excel file ?

I don’t understand your process my friend, can u send me a sample from the 1st step to the last step plz ?

In my excel file, i have this :

image

The name of my Excel file is : Excel Test

@Soudios

Try as below

Hope this may help you

Thanks

1 Like

@Soudios - Please check this…Convert Date_Sou.zip (43.2 KB)

Note: The reason why the Invoke code method is used because it is very efficient when you dealing with huge data…

1 Like

@prasath17

Something goes wrong

i also tried this :



image

@Soudios - please look at my workflow closely and try to mimic all the steps.

In your invoke code…you didn’t added Dt. Click on Edit arguments and add dt in/out as datatable variable.

Also dt should be your read range output variable.

1 Like

@prasath17

i changed dt to DT that’s the only difference in my first example.

I changed to dt :

@Soudios - please show me your edit arguments in invoke code.

1 Like

@prasath17

dt.AsEnumerable().ToList().ForEach(Sub(row) row(“Date d’entrée”)=DateTime.ParseExact(row(“Date d’entrée”).ToString.Trim,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yy”))

@Soudios - Thanks…Please click on the “Edit arguments”(Not Edit code) in the invoke code and share the screenshot…

1 Like

@prasath17

image

@Soudios - hmm looks only…not sure where is the error…

This is the workflow I shared, and you can see the output on your left…

1 Like

@Soudios - Now i dont see any errors in the Invoke Code activity…did it produced the output??

1 Like

no output

@Soudios - Please share the screenshot of your spreadsheet??

1 Like

Hi @Soudios

use this code

dt.AsEnumerable().ToList().ForEach(Sub(row) row(“Date d’entrée”)=DateTime.ParseExact(row(“Date d’entrée”).ToString.Trim,“MM/dd/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yy”))

also after reading the excel , try using write line to display this

dt.Rows(0)(“Date d’entrée”).ToString
and check what format of date is displaying

1 Like

@NIVED_NAMBIAR - Correct me if i am wrong, I didnt include HH:mm:ss because when I tested it worked fine without that. In Sou’s case, he didnt included HH:mm:ss then at least it should throw an error right??

1 Like