In C#, an OLE Automation date (OA date) is a double where the whole part counts days since December 30, 1899, and the fraction is the time of day (0.5 is noon).
DateTime.FromOADate converts that number to a DateTime. It is useful with Excel files and COM objects. For modern dates an Excel serial number equals the OA date.
This is a static member of System.DateTime. You call it with the type name, such as DateTime.FromOADate(...). DateTime holds a date and time of day with a Kind of Utc, Local, or Unspecified.
Syntax
Call it with the type name and a double.
C#
DateTime a = DateTime.FromOADate(0); // 1899-12-30
DateTime b = DateTime.FromOADate(46344.5); // 2026-11-18 12:00
DateTime c = DateTime.FromOADate(45000); // 2023-03-15
Call
What it does
DateTime.FromOADate(0)
The origin: December 30, 1899 at midnight.
DateTime.FromOADate(46344.5)
Day 46344 plus half a day (noon).
dt.ToOADate()
The opposite direction.
The result has Kind.Unspecified and is accurate to the millisecond. Valid values are greater than -657435 and less than 2958466.
Library declarations
C#
public static DateTime FromOADate(double d);
Parameters
Parameter
Description
d
Required. A double: days since December 30, 1899, with the fraction as time of day.
Return Value
Return Value
Description
DateTime
The date and time that the OA date stands for, with Kind.Unspecified.
C# Examples
Example 1 — Day Zero and Day One
Convert 0, 1, and 1.5 to see the origin and the time fraction.
C#
using System;
using System.Globalization;
class Program {
static string Show(DateTime d) => d.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
static void Main() {
Console.WriteLine(Show(DateTime.FromOADate(0)));
Console.WriteLine(Show(DateTime.FromOADate(1)));
Console.WriteLine(Show(DateTime.FromOADate(1.5)));
}
}