I am using below code in an invoke code to check if a date is of particular format then change it to a different format, but I am getting error.
Please help!
dt.AsEnumerable.ToList.ForEach(Sub(row)
If Date.TryParseExact(row("Date"),“MM/dd/yyyy hh:mm:ss”,Nothing,Globalization.DateTimeStyles.None,Nothing).ToString) Then
row("Date")= DateTime.ParseExact(row("Date"),“MM/dd/yyyy”,CultureInfo.InvariantCulture).toString
End If
End Sub
)
dt.AsEnumerable.ToList.ForEach(Sub(row)
If DateTime.ParseExact(row("Date").Tostring,"MM/dd/yyyy hh:mm:ss",Nothing,System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None,Nothing).ToString) Then
row("Date")= DateTime.ParseExact(row("Date").Tostring,"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture)
End If
End Sub
)
What is the condition in the If activity? You need to provide the condition in the IF activity
dt.AsEnumerable.ToList.ForEach(Sub(row)
If DateTime.ParseExact(row("Date").Tostring,"MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString) Then
row("Date") = DateTime.ParseExact(row("Date").Tostring,"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture)
End If
End Sub
)