DateTime To Float

Posted on 2011-10-05
Last Modified: 2013-11-23
I have a Delphi DateTime in the registry represented as a float (i.e 90074.3829327199).  The problem is that I need to take a DateTime in C# and represent it in the same fashion.  Does anyone know how to do this?
Question by:Todd710
    LVL 6

    Accepted Solution

    I'm not 100% sure about it, but it sounds like it's an OLE Automation date. If that's the case the methods ToOADate and FromOADate of the DateTime class might be of use.
    See and for details.

    Hope that helps.
    LVL 4

    Expert Comment

    I once solved a similar problem by removing the decimal character so it ends up as an "Int64" (aka "long") type.
    That way, you can use it as "ticks" when creating the DateTime.

    Int64 ticks = createTicksFromValue(90074.3829327199);  // making it into 900743829327199
    DateTime mydate = new DateTime(ticks);

    But I'm not sure if this is the right approach for this, but I think it's worth mentioning :-)

    Author Closing Comment

    You save my bacon thanks for the quick answer!  I was that indeed.
    LVL 6

    Expert Comment

    You're welcome.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now