I have three varaibles stored as integers in a MySQL database.
$d1, $d2 , $d3.
Lets say:
$d1 = 09
$d2 = 11
$d3 = 2002
How would I selects all records within the last 28 days.
In MySQL, a solution could be this:
$sql = "SELECT * FROM TTD WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 28";
Since the varaibles are not a date column, and are integers, is there anyway I could do this.
I tried:
$sql = "SELECT * FROM TTD WHERE TO_DAYS(NOW()) - TO_DAYS("$d3-$d1-$d2") <= 28";
Or is there any other method with DBI that could do carry out this job?