I am facing issue with date format. Can you please help me.
I have an excel in open date column in that few rows have date in dd-MM-yyyy format and few rows have MM-dd-yyyy format. I want the all the dates to be in dd-MM-yyyy format only.
How do I convert all the rows to dd-MM-yyyy format without using for each row activity.
Thank you but I am getting error exception has been thrown by the target of an invocation.
And when I use the same code in assign activity I am getting error as expression does not produce a value.
' Assuming dt is your datatable variable containing the dates
' Loop through each row in the datatable
For Each row As DataRow In dt.Rows
' Check if the date format is MM-dd-yyyy
If DateTime.TryParseExact(row("Open Date").ToString(), "MM-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, Nothing) Then
' If it is MM-dd-yyyy, convert it to dd-MM-yyyy
row("Open Date") = DateTime.ParseExact(row("Open Date").ToString(), "MM-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")
End If
Next