Problem converting to DateTime

I am updating an API 1.0 desktop app to API 2.0 so I can use some of the new features like the DateTimePicker and PDFs. To retrieve a date from the database I tried

var d As New DateTime(rs.Field(“BoardExpiry”).StringValue)

where the data passed is in SQLDate format.

The error message says “There is more than one method with this name, but it does not match any of the available signatures.” and “var d as New DateTime” is highlighted.

I couldn’t find anything in the docs that this should work and hope that I don’t have to parse the year, month and day to put it in the comma separated format shown in the docs.

I am also wondering if my problem relates to using a recordset instead of a rowset. I am hoping this is not the case as its a fairly big app and changing everything to rowsets will add several days to my project.

I did find a work around with my old code with the API 1 Date object and using it in the DateTime Constructor.

The meaning of the message is “there are many methods whose name is DateTime, but no one takes a String as a parameter”.

If in the Documentation you search for “DateTime constructor” - dont type the double quotes - you will see that there are 4 constructors for DateTime. And on top of that there is

with these examples:

Var SQLDateTime As String = "2019-08-01 11:00"
Var myDate1 As DateTime = DateTime.FromString(SQLDateTime)

Var SQLDate As String = "2019-08-01"
Var myDate2 As DateTime = DateTime.FromString(SQLDate)

Why not just use



As Gilles stated, you can’t use a Constructor (“new”) to instantiate a DateTime from an SQLDateTime string - you have to use the shared method DateTime.FromString().