I don’t have your code to try this for sure, but
day(theDate,eval('x-7'))
might work. Note that eval(expression)
takes a quoted string – the expression – or it takes the result of a string assignment such as
$MyString="x-7";
day(theDate,eval($MyString))