• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1445
  • Last Modified:

DateTime To Float

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?
0
Todd710
Asked:
Todd710
  • 2
1 Solution
 
effesCommented:
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 http://msdn.microsoft.com/en-US/library/system.datetime.tooadate%28v=VS.80%29.aspx and http://msdn.microsoft.com/en-us/library/system.datetime.fromoadate%28VS.80%29.aspx for details.

Hope that helps.
0
 
theHollowCommented:
Hello
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 :-)
0
 
Todd710Author Commented:
You save my bacon thanks for the quick answer!  I was that indeed.
0
 
effesCommented:
You're welcome.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now