$__timefilter postgresql

SELECT myValue FROM myData
Where myData.myValue = 1 AND $__timeFilter(mydatabase.timestamp)
ORDER BY myData.timestamp ASC

If this query returns NULL, I need to find out the last entry for myValue before the time period specified by __timefilter. Basically, if I get NULL, I can’t tell whether myValue is 1 or 0 during the _timefilter period because there was no entry during that time (myValue didn’t change). But if I can find out the last value before that, I find my answer.

can someone help please?