I have an employees
table with a field called start
which is a unix_timestamp of the date the employee started. I'm calculating their most recent anniversary using a loop in PHP
$year_start = $employee['start'];
while(strtotime('+1 year', $year_start) <= time()){
$year_start = strtotime('+1 year', $year_start);
}
That works fine, but I'd like to do it as a "virtual field" in the SQL query. Anyone got a clever MySQL query that'll get the most recent anniversary in unix_timestamp?