In C#, DateTime.ToOADate() returns a double. The whole part is the number of days since December 30, 1899. The fraction is the time of day: 0.5 is noon and 0.25 is 6 AM.
Excel and COM use this style of number, so it is handy when you write dates to spreadsheets. Use DateTime.FromOADate to turn the number back into a date.
This is an instance member of System.DateTime. You call it on a DateTime value, such as dt.ToOADate(...). DateTime is a struct, so every value is copied and never changed in place.
Syntax
Call it on a DateTime. It takes no arguments.
C#
DateTime dt = new DateTime(2026, 11, 18, 12, 0, 0);
double oa = dt.ToOADate(); // 46344.5
DateTime back = DateTime.FromOADate(oa); // same date
Call
What it does
dt.ToOADate()
Days since 1899-12-30 as a double.
new DateTime(1899, 12, 30).ToOADate()
The origin, 0.
DateTime.FromOADate(oa)
The opposite direction.
Print the number with ToString(CultureInfo.InvariantCulture) so the decimal point is always a dot.
Library declarations
C#
public double ToOADate();
Parameters
Parameter
Description
None
ToOADate() takes no parameters.
Return Value
Return Value
Description
double
The OLE Automation date: whole days since December 30, 1899, plus the time of day as a fraction.
C# Examples
Example 1 — Day Zero and Day One
Show the OA date for December 30 and 31, 1899.
C#
using System;
class Program {
static void Main() {
Console.WriteLine(new DateTime(1899, 12, 30).ToOADate());
Console.WriteLine(new DateTime(1899, 12, 31).ToOADate());
}
}
Output
0
1
How It Works
Origin. December 30, 1899 is the starting day, so the value is 0.
Next day. December 31 is one whole day later, so the value is 1.
Whole numbers. A double that has no fraction prints without a decimal point.
Midnight times. Both dates are at 00:00:00, so the fraction is zero.
Example 2 — Date, Noon, and Six AM
Convert November 18, 2026 at three times of day.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
CultureInfo inv = CultureInfo.InvariantCulture;
Console.WriteLine(new DateTime(2026, 11, 18).ToOADate().ToString(inv));
Console.WriteLine(new DateTime(2026, 11, 18, 12, 0, 0).ToOADate().ToString(inv));
Console.WriteLine(new DateTime(2026, 11, 18, 6, 0, 0).ToOADate().ToString(inv));
}
}
Output
46344
46344.5
46344.25
How It Works
Day count. November 18, 2026 is day 46344 after December 30, 1899.
Noon. Twelve hours is half a day, so the fraction is .5.
Six AM. Six hours is a quarter of a day, so the fraction is .25.
Invariant text. The invariant culture keeps the decimal separator a dot on every computer.
Example 3 — Exact and Lossy Round Trips
Round trip a clean value and one with a tiny extra tick count.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
DateTime dt = new DateTime(2028, 2, 29, 18, 0, 0);
double oa = dt.ToOADate();
Console.WriteLine(oa.ToString(CultureInfo.InvariantCulture));
Console.WriteLine(DateTime.FromOADate(oa) == dt);
DateTime fine = new DateTime(2026, 11, 18, 14, 30, 45).AddTicks(5);
Console.WriteLine(DateTime.FromOADate(fine.ToOADate()) == fine);
}
}
Output
46812.75
True
False
How It Works
Leap day at 6 PM. February 29, 2028 at 18:00 is day 46812 plus three quarters of a day.
Clean round trip. The value has no extra ticks, so converting back gives an equal date.
Five extra ticks. That is half a microsecond, finer than the millisecond resolution of an OA date.
Lossy. The tiny part is lost on the way, so the last comparison prints False.
Frequently Asked Questions
A double with days since December 30, 1899 and the time of day as a fraction.
For dates after March 1, 1900, yes. Excel serial numbers match OA dates.
OA dates keep only whole milliseconds, so finer ticks are lost.