Expected class Date, but got String

DIM d as new date dteSyncLog = d.SQLDateTime

dteSyncLog is a property.
I think this is so… confusing… and in this case parseDate was no help!

SQLDateTime is a string. Are you sure dteSyncLog is a string, because according to your error it’s a Date object.

what is the datatype of dteSyncLog?

d.SqlDateTime is a STRING, therefore dteSyncLog must be a string in this case.

perhaps what you want is

dteSyncLog=d

Or to make a copy of that date:

dteSyncLog = new Date( d )

OK, my fault. I must write very bad.

I write again:
Properties >> dtedteSyncLog as Date

DIM d as new date dteSyncLog = d.SQLDateTime

Error message: “Expeected class Date, but got string”


I now look in the documentation, Language Reference, then there is no Property named Date.
But it’s possible to select Date in the IDE…!

My initial thought was, “if there is a Date then use it as Date. It’s there for a reason!”
However, it seem as if I miss something and then I must save Dates as String. (I have no problem with that if that’s how it’s suppose to be done!)

[quote=153123:@Dave S]what is the datatype of dteSyncLog?

d.SqlDateTime is a STRING, therefore dteSyncLog must be a string in this case.

perhaps what you want is

dteSyncLog=d [/quote]

Dave had the answer here.
d.SQLDateTime returns a String and you’re trying to assign the string to a date object. :slight_smile:

[quote=153378:@Jakob Krabbe]DIM d as new date
dteSyncLog = d.SQLDateTime[/quote]

DIM d as new date dteSyncLog = d

Assuming dteSyncLog is a date object.

You can do:

DIM d as new date
  dteSyncLog = d

and then get the SQLDateTime from dteSyncLog to a string.

s = dteSyncLog.SQLDateTime

Thank you!
It answers my original question! :slight_smile:

MsgBox str(dteSyncLog)
MsgBox str(dteSyncLog.SQLDate)

[quote=153385:@Jakob Krabbe]Thank you!
It answers my original question! :slight_smile:

MsgBox str(dteSyncLog)
MsgBox str(dteSyncLog.SQLDate)[/quote]

You don’t need Str() as dteSyncLog.SQLDate returns a string :slight_smile:

Hmm… Makes sense…!! Sort of!!

OMG!!! I learn so much today!!

OMG = Oh my God

To remove two lines you can actually do this instead (skip d…) :wink:

dteSyncLog = new date // Sets dteSyncLog to Now.
msgbox dteSyncLog.SQLDate

Since dteSyncLog is a Property :slight_smile:

OK, thank you.
But the code is not IRL…
Meaning, it’s just for test purpose.
I was just testing the Date-property… but sure, maybe in other situation!

Thank you very much for the valuable information!