sql based device timestamping