---
name: "dateToNumber"
type: command
status: ok
groups: ["Environment"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/dateToNumber
revid: 378087
updated: 2026-02-12T17:31:59Z
---

# dateToNumber

*Command · Environment · Arma 3 v0.50 · introduced in Arma 2 v1.00*

## Description

Convert a date to a float number, based on Jan 1st 00:00:00 = 0 and Dec 31st  23:59:59 = 1.
The same day and time in leap year will be different after 28th of February and 23:59 on 31st of December will be 1.00274.

This is how this command works. The 365 days of the year are presented in range 0..1. So each day will be:

```sqf
1 / 365 = 0.00273973
```

In a leap year there are 366 days, so the range will increase by 1 day:

```sqf
1 / 365 * 366 = 1.00274
```

In short, in a normal year the command returns in range 0...1 in a leap year it will return in range 0...1.00274.

## Syntax

```sqf
dateToNumber date
```

**Parameters:**

- `date`: Date

**Returns:** [Number](../topics/Number.md)

## Examples

### Example 1

```sqf
_float = dateToNumber [2035, 7, 6, 12, 0]; // 0.510959
```

### Example 2

```sqf
dateToNumber date; // returns float number for the current date
```

### Example 3

Calculate days from 1/1/1970:

```sqf
_fnc_daysFromEpoch =
{
    private _year = param [0];
    private _days = 0;
    for "_i" from 1970 to _year - 1 do
    {
        _days = _days + round linearConversion [0, 1, dateToNumber [_i, 12, 31, 23, 59], 0, 365, false];
    };

    _days + linearConversion [0, 1, dateToNumber _this, 0, 365, false];
};

hint str (date call _fnc_daysFromEpoch);
```

## See also

[date](../commands/date.md) · [dayTime](../commands/dayTime.md) · [time](../commands/time.md) · [numberToDate](../commands/numberToDate.md)

<sub>Source: [BI Community Wiki — dateToNumber](https://community.bistudio.com/wiki/dateToNumber) (revision 378087).</sub>
