What Range property distinguishes a double from a datetime?

L

LJ

I am using vs2005 and c#.

I am passing a range object into C# and trying to determine what type
of value it is. In case it's a datetime I want to convert it using
DateTime.FromOADate. I can't find the right property to help me
distinguish a datetime from a double. Excel seems to know. I see the
Range.NumberFormat looks different but using this seems like a real
kludge.
 
A

AA2e72E

I could be wrong but I don't think Excel understands DATETIME although a cell
format can show it. The closest is

typename(Range("c1").value)

would return Date if c1 contains a timestamp or a date.
 
L

LJ

In .NET there does not seem to be a Value property. I use Value2.
Text also displays the text value. I have tried the get_Value method
but it takes a RangeValueDataType argument which is really what I am
looking for.

Excel seems to know when you enter a date that it should be transformed
into a double for storage but displayed as a date (it automatically
stores "m/d/yyyy" as the format for example). I am wondering if it
stores this information anywhere such as a datatype field or if it just
does the translation and set the format.

It seems like storing the RangeValueDataType object as a property of
the range would have been a nice thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top