# ExcelDateSystemConverter

Converts dates to and from Excel serial values using the workbook's configured date system.

Class 

`OfficeIMO.Excel`

**Namespace**

`OfficeIMO.Excel`

**Assembly**

`OfficeIMO.Excel`

**Source revision**

`273d35d5ba8a` with working tree changes

**Source**

[ExcelDateSystemConverter.cs:35](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelDateSystemConverter.cs#L35)

**Modifiers**

static

Converts dates to and from Excel serial values using the workbook's configured date system.

## Inheritance

- object
- ExcelDateSystemConverter

## Remarks

A serial counts days, and its whole part is the day Excel reports for it. Serials hold whole milliseconds: values are stored truncated to the millisecond, so a time just before midnight stays on its own day, and serials read back rounded to the nearest millisecond, never past the last millisecond of the serial's day. The time always comes from the serial's own fraction; a date system's epoch moves only whole days, as integer arithmetic, so the 1904 offset never changes how a fraction rounds.

Filter members 

Show inherited

## Methods

`public static DateTime FromSerial(double serial, ExcelDateSystem dateSystem)` [#](#method-fromserial-double-officeimo-excel-exceldatesystem)

[ExcelDateSystemConverter.cs:65](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelDateSystemConverter.cs#L65)

Converts an Excel serial value from the selected date system to a date. In the 1900 system, serial 60 denotes Excel's fictitious February 29 and maps to February 28 because DateTime cannot represent it. Negative serials extend the epoch backwards in both systems, December 31, 1899 or January 1, 1904, with fractional values representing elapsed portions of a day.

Parameters

**serial double required**

**dateSystem OfficeIMO.Excel.ExcelDateSystem required**

Returns

`DateTime`

`public static double ToSerial(DateTime value, ExcelDateSystem dateSystem)` [#](#method-toserial-datetime-officeimo-excel-exceldatesystem)

[ExcelDateSystemConverter.cs:35](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelDateSystemConverter.cs#L35)

Converts a date to the serial value used by the selected Excel date system. Dates before serial 0, December 31, 1899 in the 1900 system and January 1, 1904 in the 1904 system, extend the epoch backwards as negative serials in both systems. Excel shows those cells as ####; OfficeIMO reads them back as the same date.

Parameters

**value System.DateTime required**

**dateSystem OfficeIMO.Excel.ExcelDateSystem required**

Returns

`double`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Fields

`public const double Date1904OffsetDays` [#](#field-date1904offsetdays)

[ExcelDateSystemConverter.cs:26](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelDateSystemConverter.cs#L26)

Number of days between the Excel 1900 and 1904 date-system epochs.

Value: `1462`

<!-- PowerForge markdown artifact sha256:E220FF4791F7E388DA692B0918259785C9A07E14D2D88C61BBA059ECBAAAA2EC -->
