In my evedb.info efforts I need a quick way to expire old market orders. The CSV has a duration column that is an integer number of days. Postgres allows its users to typecast between various data types in SQL so there doesn't need to be a SELECT duration FROM ... ; (in code) to_delete = Time.now + duration.days ; DELETE FROM ... WHERE duration < to_delete;
It just so happens that the form for casting an integer to do math with a timestamp is a bit funky. An integer may not be directly added to a timestamp. The magic is:
SQL:
-
DELETE
-
FROM foo
-
WHERE now()> (created_on + CAST( (duration || ' days') AS INTERVAL));
The || ' days' I don't understand just yet but it works!

