I want to convert datetime to string. I have declared DATE_PLACED_IN_SERVICE as datetime in SQL server database and want to convert it to string in my source code. I am getting the error: "Unable to cast object of type 'System.DateTime' to type 'System.String'"
Here my source code:
If rdmysql.IsDBNull(rdmysql.GetOrdinal("DATE_PLACED_IN_SERVICE")) = False Then
Dim ServiceDate As Date = rdmysql.GetString(rdmysql.GetOrdinal("DATE_PLACED_IN_SERVICE"))
ServiceTxt.Text = Format(ServiceDate, "yyyy-MM-dd")
End If