Search code examples
c#ms-accesspick

How to convert an internal numeric date to Access Date/Time format?


I get some data from a PICK/UniVerse database that includes dates in a 4 or 5 character numeric format. Here are some examples .. I grabbed the date values from the database, and compared it to the date being shown in an application:

9832       12/1/1994
10027      6/14/1995
10594      1/1/1997

Is it possible to convert these into something that can be put into Access as a Date/Time value?

As A test, I put 9832 in Excel as a General format and then change it to Short Date, it comes up as 12/1/1926. So it's off by exactly 68 years. This was true for 10027 and 10594 as well.


Solution

  • In C# you can use DateTime.FromOADate

    DateTime dt = DateTime.FromOADate(41481);
    

    Returns a DateTime equivalent to the specified OLE Automation Date.

    That will give you:

    dt = {26/07/2013 12:00:00 AM}
    

    Later on you can insert that Date in your Access database.