0

I use a function public static object getContent(String keyword, object StartTime, object EndTime) { alert(StartTime); }

set cell A1 to 18-07-2012.And when calling =getContent("africa",A1,"04-09-2012") dispalys 41108.what it means?Why its not taking value in A1!!!

user1618820
  • 109
  • 1
  • 2
  • 11

1 Answers1

1

Excel has no built-in date/time data type. In Excel, date/times are formatting options for the double data type. You can declare an Excel-DNA function as taking a DateTime parameter to have the passed-in doubles converted to DateTime automatically, or you can do the conversion yourself using DateTime.FromOADate() (since the Excel double encoding matches the COM/OLE date implementation).

Govert
  • 16,387
  • 4
  • 60
  • 70
  • Thanks for the help.I tried DateTime.FronOADate() but got the same output as 41108.Sadly I need to use object datatype because sometimes it should accept a string value rather than TODAY() .Is there anyway to achieve this? – user1618820 Sep 28 '12 at 09:07
  • If you call DateTime.FromOAData(41108) you get a DateTime (2012/07/18 00:00:00). If you return this value to Excel and format the cell as a Date/Time, Excel will display the corresponding date. – Govert Sep 28 '12 at 19:59