« First Trip On TransitE2328 Linker error while emitting metadata »

Converting TDateTimes to System.DateTimes and back

03/10/11

  01:41:56 pm, by Nimble   , 102 words  
Categories: Programming

Converting TDateTimes to System.DateTimes and back

It's not straight-up obvious how to convert the Borland and Microsoft formats back and forth in code, but it does end up being pretty easy.

TDateTimes are in "OA" format, which is OLE/COM-compatible. The functions that convert back and forth to the OLE format work just fine for TDateTimes as well.

MSDate := DateTime.FromOADate(BorlandDate);
BorlandDate := MSDate.ToOADate();

The syntax is nigh identical on the C# side apart from the assignment operator (= instead of :=).

Note that if the TDateTime arrives as an object in C# somewhere, you can simply cast it as a double; you do not need to cast it specifically as a TDateTime.

No feedback yet

December 2017
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Ritchie Annand's blog of everything except sports (...and who knows? I may break that rule some day)

Search

  XML Feeds

powered by b2evolution