c3f
c3f

Reputation: 65

converting a datetime to string resulting in error "Conversion from string ""dd.MM.yyyy"" to type 'Integer' is not valid."

I have a date, being retrieved from a recordset:

AdoRecordSet("Date").Value

which has the value:

#12/7/2018 12:00:00 AM#

When I try to convert it to a string and show it in a textbox:

textbox1.Text = AdoRecordSet("Date").Value.ToString("dd.MM.yyyy")

This causes an error:

Message: "Conversion from string ""dd.MM.yyyy"" to type 'Integer' is not valid."

I am trying to figure out why dtDate.ToString("dd.MM.yyyy") is causing the error.

Upvotes: 2

Views: 1290

Answers (1)

c3f
c3f

Reputation: 65

For some reason when reading the value from a ADODB.RecordSet, it could not be implicitly converted to Date from DateTime.

It worked with CDate(AdoRecordSet("Date").Value.ToString("dd.MM.yyyy")

Upvotes: 1

Related Questions