Yes, as @chairstacker mentioned you can do it using a SQL sensor. SQL sensors can be setup in the UI on the Integrations page. For the following, make sure to set “state” for the column value.
SELECT state from states
where entity_id = 'sensor.YOUR_SENSOR'
and last_updated_ts <= strftime('%s', 'now','-24 hours')
order by last_updated_ts DESC LIMIT 1;
Keep in mind that, depending on the update frequency of your sensor and other factors, this may not be a 100% accurate reflection of the actual situation you are measuring. Since your database won’t necessarily have a value saved exactly 24 hours ago, it’s usually a good idea to use “>=” or “<=” to get one of the closest values.
EDIT: Updated for 2023.2 database schema update