How do I get rid of the duplicate code in this query?
I would just duplicate the expression. It is possible to structure your query so that you only define the expression once, but it will end up being more verbose, as it requires that you define the field you're WHEREing as a column in a subquery and then do the WHERE on the outer field.
SELECT * FROM (
  SELECT *, (&quot;last done&quot; + &quot;auto time span&quot;::interval) AS &quot;new last done&quot;
  FROM personal.&quot;time tabs&quot;
  WHERE &quot;reset automatically&quot; = true
) AS inner_query
WHERE &quot;new last done&quot; &lt; now();

As long as you don't have ORDER BY or LIMIT on the inner query, the query planner should be able to tell that it's logically equivalent to having that WHERE in the inner query, so actual query execution shouldn't be affected.