# Date, Time and Datetime Fields

> The eXtremeDB `datetime` type is a 64-bit integer value used to store the date and time in databases. The precision of `datetime` values is determined by the runtime parameter `DATETIME_PRECISION`. Numerically, the precision represents the number of ticks per second. The default value for `DATETIME_PRECISION` is 1, which means that the database stores a `datetime` value as the number of seconds since the EPOCH (i.e. 00:00:00 UTC 1 January 1970). The resolution of `datetime` fields can be changed by an application at runtime to a resolution ranging from 1 (to store the number of seconds) to 1000000000 (for the number of nanoseconds). (However, note that the Java Date type uses millisecond resolution and the C# Datetime uses 100-nanosecond resolution. So these limitations apply to the database values possible with these native language APIs.)

> It is important to note that the value of `DATETIME_PRECISION` is a per-process parameter; all processes working with the same database must set the same value for `DATETIME_PRECISION`. Respectively, all databases accessed from a given process will have the same precision.

> ## Arithmetic on Date, Time and Datetime Fields

> When using `date`, `time` or `datetime` fields in SQL, if any operand of the arithmetic expression is of type `date`, `time` or `datetime`, then the other operand is converted to `datetime` and the result of expression is of type `datetime`. The result will be formatted for output depending on the original type. So, for example a `date` field `day` could be incremented `day+5` and the result will be of type `date`.

> However, note that outside SQL, `date` and `time` fields are `uint4` values, while `datetime` fields are `uint8`. There are no special "operations" defined for these fields. The above rule is applicable to SQL only.

> ## Native Language APIs

> The APIs for managing date, time and datetime fields are specific to the programming language used. Please use the links below to view detailed explanations and examples for your development environment:

> SQL | Managing `date, time` and `datetime` fields in SQL
> C | Managing `date, time` and `datetime` fields in C
> C++ | Managing`date, time` and `datetime` fields in C++
> Java | Managing D`ate` fields in Java
> Python | Managing ``datetime`` fields in Python
> C# | Managing `Datetime` fields in C#