C# DateTime FromOADate() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
DateTime

Definition

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
CallWhat 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

ParameterDescription
dRequired. A double: days since December 30, 1899, with the fraction as time of day.

Return Value

Return ValueDescription
DateTimeThe 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)));
    }
}

How It Works

  1. Zero is the origin. OA date 0 is December 30, 1899 at midnight.
  2. One whole day. Adding 1 moves one calendar day forward.
  3. Fraction is time. The .5 in 1.5 means half a day, which is 12:00.
  4. Unspecified Kind. The method does not say whether the result is local or UTC.

Example 2 — Noon and Six in the Morning

Convert known OA dates for November 18, 2026.

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(46344.5)));
        Console.WriteLine(Show(DateTime.FromOADate(46344.25)));
    }
}

How It Works

  1. Day number 46344. That many days after December 30, 1899 is November 18, 2026.
  2. .5 is noon. Half of 24 hours is 12 hours.
  3. .25 is 6 AM. A quarter of 24 hours is 6 hours.
  4. Same calendar day. Only the fraction changed, so both results are on November 18.

Example 3 — Excel Serial and Bad Values

Convert an Excel-style number, a negative fraction, and a number that is too large.

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(45000)));
        Console.WriteLine(Show(DateTime.FromOADate(-1.5)));
        try {
            DateTime.FromOADate(3000000);
        } catch (ArgumentException) {
            Console.WriteLine("OA date out of range");
        }
    }
}

How It Works

  1. Excel serial. Excel shows 45000 for March 15, 2023, which matches the OA date.
  2. Negative value. -1.5 is day -1 (December 29, 1899) plus half a day of time.
  3. Too large. The limit is 2958466 (the end of year 9999), so 3000000 is rejected.
  4. ArgumentException. The code catches it and prints a short message.

Frequently Asked Questions

A double where the whole part is days since December 30, 1899 and the fraction is the time of day.
For dates after March 1, 1900, yes. Excel serial numbers match OA dates.
December 30, 1899 at 00:00:00.
ArgumentException, when the number is outside the valid range.
Unspecified.

Next: GetDateTimeFormats()

Return many string forms of a DateTime, for all or one standard format letter with System.DateTime.

GetDateTimeFormats() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful