# Managing Datetime Fields in Python

> As explained in the Datetime FIelds page, a field of `datetime` type is a 64 bit integer value used to store the date and time in databases and the precision of d`atetime` values is determined by the runtime parameter `DATETIME_PRECISION` which represents the number of ticks per second. The default value for `DATETIME_PRECISION` is 1000, which means that the database stores a `datetime` value as the number of milliseconds since the EPOCH (i.e. 00:00:00 UTC 1 January 1970).

> For example , the following code snippet defines a `Datetime` field `d` and a sequence of `datetime` values `sd`:

>         class T
>         {
>             datetime d;
>             sequence<datetime> sd;
>         }

> The resolution of `Date` fields can be changed by an application via the runtime option ``RT_OPTION_DATETIME_PRECISION``. The `DATETIME_PRECISION` can be set to 1 to store the number of seconds, or 1000000 (1,000,000) to store the number of microseconds. For example:

>         exdb.runtime_setoption(exdb.RuntimeOption.MCO_RT_OPTION_DATETIME_PRECISION, 1000000)

> The following code snippet demonstrates how to store and load `Date` values using SQL:

>         import datetime
>         ...
>         d = datetime.datetime(2011, 9, 10, 9, 30)
>         sd = [datetime.datetime(2011, 9, 10, 9, i) for i in range(1,30) ]
>         cursor = con.cursor()
>         cursor.execute("INSERT INTO T VALUES(?,?)", (d, sd))

>         ...

>         cursor = con.cursor()
>         cursor.execute("SELECT d, sd FROM T")
>         for row in cursor:
>         d,sd = row
>         sds = [item for item in sd]
>         print "d: %s.   sd : %s" % (d, sds)
>         cursor.close()