[ExcelDna] Extracting Date value from a input array

476 views
Skip to first unread message

Ram

unread,
Apr 15, 2010, 12:06:00 PM4/15/10
to ExcelDna
Hi Everybody,

My C# function takes an array as an input. One of the values in the
array is a date value. When I iterate though the array to retrieve the
date value I get the numeric equivalent of Excel date representation
instead of a string. How do I convert this to a valid .NET data time
object?

For example “4/15/2010” is returned as 40283.0. Sample code

[ExcelFunction]
public static object TestFunc(object[,] parameters)
{
DateTime.Parse(parameters[0, 0].ToString()); // does not work
Double d = parameters[0, 0]; // d is 40283.0
}

Any help greatly appreciated.
Thank you,
Ram

--
You received this message because you are subscribed to the Google Groups "ExcelDna" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.

Govert van Drimmelen

unread,
Apr 16, 2010, 4:02:15 AM4/16/10
to ExcelDna
Hi,

Try this:
DateTime dt = DateTime.FromOADate(d);

--Govert--

Ram

unread,
Apr 16, 2010, 4:44:52 PM4/16/10
to ExcelDna
Thank you Govert.

Personally I do not believe in the open source model BUT ExcelDna
rocks!!! Keep up the good work!

Govert van Drimmelen

unread,
Apr 17, 2010, 9:11:27 AM4/17/10
to ExcelDna
Hi Ram,

I'm glad you like ExcelDna.

You are very welcome not to look at the source code,
and send money via PayPal ;-)

--Govert--

Ram

unread,
Apr 19, 2010, 3:27:46 PM4/19/10
to ExcelDna
Hi Govert,

Not look source code…..hmmm well you see commercial third party does
let you buy the rights to look into there source code. So I was to pay
for ExcelDNA I should be able to take a peep at the source code for
debugging, etc.

As for sending money via PayPal, if you send me an invoice I can ask
my manager to pay! Anyways I might me going the way of Add-in express
or managed XLL as I am sure my users will demand a host of advanced
features once the POC is out!:)

Regards,
Ram
Reply all
Reply to author
Forward
0 new messages