Tommy Sin

Tommy Sin

  • NA
  • 19
  • 104.3k

Change Excel Date Format using C#

Feb 18 2011 2:33 PM
Hi,
I am just wondering how I can change the Excel Date Format using C#.
I declared the date as string like "1-Apr-09" and I know it shows 39,904 if I change the format cell in excel.
How do I do that using C#? Please refer to the code below. Could anyone please implement
double DateChangeToDouble(string a) below? Thank you so much.



Class Program
{
        double DateChangeToDouble(string a)
        {
                double b;
                // Implementing a to change to double value here
                return b;
        }

        static void Main(string[] args)
        {
                string a = "1-Apr-09";
                double b = DateChangeToDouble(a); //double b should be 39904 here.
                Console.WriteLine(b); //39904
        }
}

Answers (1)