Hey UiPath Community,
I have a question regarding Date Time
So the question is : I have multiple Date formats in my excel like dd/mm/yy ; dd-mm-yy ; dd-MMMM-yyyy and so on
So i want to convert all of those formats into a single format
Hi @Goku ,
I think you can
use read range to get data table
use for each row in data table with if check format
In this case, we will have a way to change it accordingly
Regards,
LNV
Use read range activity to read the data into datatable to dateList
(From date In dateList
Let parsedDate = DateTime.ParseExact(date, {"dd/MM/yy", "dd-MM-yy", "dd-MMMM-yyyy"}, CultureInfo.InvariantCulture, DateTimeStyles.None)
Let formattedDate = parsedDate.ToString("yyyy-MM-dd")
Select formattedDate).ToList()
Hello I have implemented the solution. I have formatted the date using DateTime.ParseExact method to format the desired format. Then store these formats in a list. Finally using while loop write the dates in each cell.
Please check it once it should be helpful .
This code will not work for the date format like 08.08.2023. If you want to add this then please add a if activity to validate this date and do the necessary format.
You can assign all the formats into an array
for eg: dateFormatsArray = {“dd/MM/yy”, “dd-MM-yy”, “dd-MMMM-yyyy”,and so on}
Loop through the DataTable: Use a “For Each Row” activity in UiPath to loop through each row in the DataTable.
Convert the dates: Inside the loop, you can use the “DateTime.ParseExact” method to convert each date to a common format.