First, when setting values to Time64Col they must be float64 s. You can do this by calling astype , for example:
new_rec = rec.astype([('a', 'i4'), ('b', 'f8')])
Then you need to convert column b in seconds from the era, which means you need to divide by 1,000,000, since we are in microseconds:
new_rec['b'] = new_rec['b'] / 1e6
Then call d.append(new_rec)
When you read the array back into memory, do the opposite and multiply by 1,000,000. You need to make sure everything happens in microseconds before inserting anything that is automatically processed by astype('datetime64[us]') in numpy> = 1.7.x
I used the solution from this question: How to get unix timestamp from numpy.datetime64
Here is the working version of your example:
In [4]: data = [(1, datetime(2000, 1, 1, 1, 1, 1)), (2, datetime(2001, 2, 2, 2, 2, 2))] In [5]: rec = np.array(data, dtype=[('a', 'i4'), ('b', 'M8[us]')]) In [6]: new_rec = rec.astype([('a', 'i4'), ('b', 'f8')]) In [7]: new_rec Out[7]: array([(1, 946688461000000.0), (2, 981079322000000.0)], dtype=[('a', '<i4'), ('b', '<f8')]) In [8]: new_rec['b'] /= 1e6 In [9]: new_rec Out[9]: array([(1, 946688461.0), (2, 981079322.0)], dtype=[('a', '<i4'), ('b', '<f8')]) In [10]: f = tb.open_file('foo.h5', 'w') # New PyTables file In [11]: d = f.create_table('/', 'bar', description={'a': tb.Int32Col(pos=0), ....: 'b': tb.Time64Col(pos=1)}) In [12]: d.append(new_rec) In [13]: d[:] Out[13]: array([(1, 946688461.0), (2, 981079322.0)], dtype=[('a', '<i4'), ('b', '<f8')]) In [14]: r = d[:] In [15]: r['b'] *= 1e6 In [16]: r.astype([('a', 'i4'), ('b', 'datetime64[us]')]) Out[16]: array([(1, datetime.datetime(2000, 1, 1, 1, 1, 1)), (2, datetime.datetime(2001, 2, 2, 2, 2, 2))], dtype=[('a', '<i4'), ('b', '<M8[us]')])