How do I check if a Variant is a TDateTime?
Asked Answered
R

1

5

I have an object, that has one value, but that value can either be an integer, string, boolean or TDateTime. So, it is a Variant.

I use VarType() to check its type, but since VarType() has no 'varDate' or 'varDateTime', I am using 'varDouble', because as far as I can gather, a TDateTime is a double.

But that returns false. I also cannot use is to check if the Variant is TDateTime. Is there a way, or should I make some sort of type variable that determines which type the value is and use that to check it?

Radford answered 13/3, 2013 at 13:59 Comment(1)
Anyway, you don't need to make your own function to check a variant type. There's already the VarIsType function to do so.Unbent
G
8

Your assumptions are incorrect; there is in fact a varDate.

Gramme answered 13/3, 2013 at 14:4 Comment(1)
@Svip: Things like that happen to me too sometimes!Gramme

© 2022 - 2024 — McMap. All rights reserved.