In the secondary database, the key is what you extract and the data is the key of the primary database. As your primary key is a unique string, your data in secondary database is also a unique string. The DB->set_dup_compare sets the comparison function for the duplicate data, so you are comparing time stamps on unique strings, not on what you extract.
As you are comparing the time stamps which are the keys of secondary database, I guess here you want to set the bt_compare function instead of the dup_compare for the secondary database.
Also, about this sentence:
secondary_key->data = ( (MY_DATA *)(primary_data->data))->timestamp;
The DBT.data should be an address, but this is a value here instead of an address.
Winter, Oracle Berkeley DB