ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VSTO Date Evaluation (https://www.excelbanter.com/excel-programming/342712-vsto-date-evaluation.html)

Bob Sullentrup

VSTO Date Evaluation
 
Folks,

I have a cell (F8) containing 7/14/2005, which translates to 38547 in the C#
code-behind.

I can translate 38547 to 7/14/2005 with the following:

day_to_process =
(Convert.ToDateTime("12/30/1899")).AddDays(Convert.ToDouble(((Excel.Range)rng Lookup.Cells[8,6]).Value2.ToString()));

Anybody have a better way?

--
Bob Sullentrup

Rob Bovey

VSTO Date Evaluation
 
Hi Bob,

I haven't got VS.NET available to test this at the moment, but how about
something like this:

DateTime day_to_process =
DateTime.Parse((Excel.Range)rngLookup.Cells[8,6]).Text);

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Bob Sullentrup" wrote in message
...
Folks,

I have a cell (F8) containing 7/14/2005, which translates to 38547 in the
C#
code-behind.

I can translate 38547 to 7/14/2005 with the following:

day_to_process =
(Convert.ToDateTime("12/30/1899")).AddDays(Convert.ToDouble(((Excel.Range)rng Lookup.Cells[8,6]).Value2.ToString()));

Anybody have a better way?

--
Bob Sullentrup




Bob Sullentrup

VSTO Date Evaluation
 
Thanks, Rob

DateTime.Parse(((Excel.Range)rngLookup.Cells[8,6]).Text.ToString());

works.


--
Bob Sullentrup


"Rob Bovey" wrote:

Hi Bob,

I haven't got VS.NET available to test this at the moment, but how about
something like this:

DateTime day_to_process =
DateTime.Parse((Excel.Range)rngLookup.Cells[8,6]).Text);

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Bob Sullentrup" wrote in message
...
Folks,

I have a cell (F8) containing 7/14/2005, which translates to 38547 in the
C#
code-behind.

I can translate 38547 to 7/14/2005 with the following:

day_to_process =
(Convert.ToDateTime("12/30/1899")).AddDays(Convert.ToDouble(((Excel.Range)rng Lookup.Cells[8,6]).Value2.ToString()));

Anybody have a better way?

--
Bob Sullentrup






All times are GMT +1. The time now is 10:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com