As explained in the Datetime FIelds page, a field of
datetimetype is a 64 bit integer value used to store the date and time in databases and the precision of datetimevalues is determined by the runtime parameterDATETIME_PRECISIONwhich represents the number of ticks per second. The default value forDATETIME_PRECISIONis 1000, which means that the database stores adatetimevalue 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
Datetimefielddand a sequence ofdatetimevaluessd:class T { datetime d; sequence<datetime> sd; }The resolution of
Datefields can be changed by an application via the runtime option. TheRT_OPTION_DATETIME_PRECISIONDATETIME_PRECISIONcan 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
Datevalues 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()