Hi, my robot takes a date from excel and pastes it into an email. The date is in the format dd.mm.yyyy, but the robot converts this date to the format: mm/dd/yyyy - how can I change it? I need the format dd.mm.yyyy
Hi @sullivanne
DateTime.ParseExact(dateFromExcel.ToString, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd.MM.yyyy")
Hie @sullivanne
try this
datetime.ParseExact(“05/12/1990”,“MM/dd/yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd.MM.yyyy”)
Cheers Happy Automation
Hi @sullivanne
Store the excel data in a string variable called Excel_Date. Then use the below datetime expression to convert to the required format.
- Assign -> Excel_Date = DateTime.Parseexact(Excel_Date.toString, "mm/dd/yyyy", System.globalization.Cultureinfo.InvariantCulture).to string("dd.mm.yyyy')
Hope it helps!!
Thank you, but I have a problem with putting the datatable into excel, because it is a string. What can I do to change the date format and be able to use excel.
Your query is quite confusing could you be more specific… @sullivanne
If possible try to share the images for our better understanding. Input and Expected output.
Read the excel data into a datatable variable
Use for each row in datatable
Assign: Excel_Date = DateTime.ParseExact(CurrentRow("DateColumnName").ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd.MM.yyyy")
Assign: CurrentRow("DateColumnName") = Excel_Date
Write range workbook
Check your machine date format and change it
Hie @sullivanne here
change build data table with Excel application scope so you get the data from Excel

after use for each row actvity
use two assign activity
1 hold the value of the column data and store in a variable form
2 Assign help you to convert your date format into your desired format
And finally your Output looks like this
Cheers Happy Automation…
Hi @sullivanne,
Please parse the date from excel and format it the way you wanted as below.
DateTime.ParseExact(strExcelDate.ToString, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd.MM.yyyy”)
Regards,
Ranjith Udayakumar
Thank You very much, but I have error: String ‘7/31/2023’ was not recognized as a valid DateTime.
Okay @sullivanne
Try the below expression,
DateTime.ParseExact(DateCol, {"MM/dd/yyyy","M/dd/yyyy","M/d/yyyy"}, System.globalization.Cultureinfo.InvariantCulture, System.globalization.DateTimestyles.None).toString("dd.MM.yyyy")
Hope it helps!!
Hie @sullivanne can you show your date format sample that have stored in excel