Load a dynamic variable to use in database query condition

I have a db table with records and one field is a timestamp.

Now I would like to filter the query with only those records that are more than a week old.

My idea/approach would be to execute a small calculation:

get the current timestamp minus 604,800 (total seconds in a week) and save that in a variable

Then I could use that variable in the condition: WHERE datetime < $variable

Is this possible?
Or is there a better way?

Community Page
Last updated: