Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,938 questions

51,875 answers

573 users

How to convert integer dates from a string array to DateTime in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = new string[]
            {
                "35582", 
                "36126",
                "37982",
                "38621",
                "39871",
                "40571",
                "41877",
                "42753"
            };

            foreach (string s in arr)
            {
                double d = double.Parse(s);

                DateTime dt = DateTime.FromOADate(d);

                Console.WriteLine("{0} = {1}", s, dt.ToShortDateString());
            }
        }
    }
}

/*
run:
   
35582 = 01/06/1997
36126 = 27/11/1998
37982 = 27/12/2003
38621 = 26/09/2005
39871 = 27/02/2009
40571 = 28/01/2011
41877 = 26/08/2014
42753 = 18/01/2017

*/

 



answered Jan 18, 2017 by avibootz

Related questions

1 answer 88 views
1 answer 134 views
3 answers 270 views
270 views asked Sep 12, 2020 by avibootz
1 answer 103 views
1 answer 222 views
1 answer 110 views
1 answer 116 views
...