the date format i am getting from excel is 19/feb/25 00:00:00 AM i want to convert into 19-feb-25. how can we do it
Hi @SSD
Try this
FormattedDate = DateTime.ParseExact(CurrentRow("Date").toString, "dd/MMM/yy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yy")
Regards,
Hi @SSD
you can use the following
DateTime.ParseExact(DateString, "dd/MMM/yy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yy")
Reference:
Hi @SSD
You can also do string manupulation for this if the format of time changes
dateStringResult = dateVariable.ToString.Split(" “)(0).Replace(”/“,”-")
Hi @SSD
Is your variable already in DateTime format?
If the data type is already in DateTime, this error would occur:

The Solution, Change the code to:
Convert.ToDateTime(CurrentRow("Date")).ToString("dd-MMM-yy")
I hope this solves your issue, if so do mark it as solution
Thank You
Happy Automation
i want it in 19-feb-25 format and i have coded the same it is giving that error
In Read Range Workbook activity, check Use display format
If possible can you please share input excel file
Regards,
Hi @SSD
Try the below syntax:
FormattedDate = DateTime.ParseExact(CurrentRow("Date").toString, "MM/dd/yyyy HH:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yy")
Hope it helps!!
Hi @SSD
The error is caused because the date time is wrongly formatted.
as per your excel, the value is 01/01/2025 18:19:55 AM which is invalid, because 18:19:55 is a 24 hour format, which you cannot mention as AM
Hi @SSD
Here is updated solution, do let me know if it works or not:
Step 1: The issue was as mentioned earlier, 24 Hour format cannot have an AM or PM. So let us first remove it from the date String:
dateValid = CurrentRow("Date").ToString.Replace(" AM", "").Replace(" PM", "")
Step 2: Update the existing assign statement with the new format of “dd/MM/yyyy HH:mm:ss”. (Previously it was “dd/MM/yyyy hh:mm:ss tt”)
dateFormatted = DateTime.ParseExact(dateValid, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yy")
The final flow:
The Output:
Hey @SSD if your date input in string format and you want to modify that date in your require format type use that logic.
cheers
First thing when you read from excel the format needs to be checked in locals pnel rather than on excel…based on the format it reads the date in UiPath is what you need to write the conversion expression
Cheers