add obtained_at in sql statement