If Cell format = "dd/MM/yy" then Situation 1 otherwise 2

How can i do that plz ?

If the the cell Date format is equal to this format “dd/MM/yy” then use invoke otherwise nothing

image

Invoke :

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

@Soudios - You can filter the dates meet your condition and write to another datatable. After that apply the above Invoke code…

1 Like

Hi @prasath17

I need something like that :

image

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

@Soudios - You have to understand what is the invoke code is doing here…

Even if you check the If condition, Invoke code will take your whole Dt so it will throw an error…

If you have different date formats in the same column…then you have to use for each loop and read each row values , check for the date formats and if its matches then you have to use the datetime.parseexact in the Assign statement…

Hope this helps…

1 Like

@prasath17

Yes that’s what i want but how can i write “if the assign = dd/MM/yy” so use date datetime.parsect

in fact i need the syntax : if the date 1 match with ''dd/MM/yy" format

@Soudios - please share the sample sheet and clearly explain which format you would like to covert and which format which one you want to ignore ?

1 Like

@prasath17

Date 1 : good format
Date 2 : wrong format

What i want is when the format Date 2 is true it will be convert to format Date 1 (dd/MM/yyyy)

If Cell “02” with date format (dd/MM/yy) = true so convert to date format ((dd/MM/yyyy) Otherwise nothing

DATE_UIPATH.xlsx (17.1 KB)

@Soudios - Please find the xaml attached…DateCheck_And_Convert.zip (53.2 KB)

You Can see the new sheet with the fixed dates(you can delete the sheet and try running again)

Again, provided code is working fine as per the sample sheet attached…If is not working with the real sheet…please use debugging tools to see where and Why is the error thrown…

Hope this helps…

@prasath17
Perfect thank you !

1 Like

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