I am facing an error while converting date formats to a preferable date format for my process.
The date format of the variable I receive is dd/MM. I get the date I want to convert from a data table named “out_dt_excel” and I store it to the variable “CurrentDate”. In the next assign activity I do this in order to convert the date format to “dd/MM/yyyy”.
I have it before also with the same format (“dd/MM”) and it worked, but now suddenly this error arise and I don’t know what I should change in order to work.
Error: Change format of current date: String ‘29 02’ was not recognized as a valid DateTime.
I tried also in the immediate CDate(CurrentDate) but I also get an exception.
What should I do? Do you have any recommendations?
year = Now.Year
If Not DateTime.IsLeapYear(year) AndAlso CurrentDate.StartsWith(“29/02”) Then year = 2024
CurrentDate = CurrentDate & “/” & year
ParsedDate = DateTime.ParseExact(CurrentDate, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)