Home:ALL Converter>MySQL unix_timestamp calculation

MySQL unix_timestamp calculation

Ask Time:2014-07-16T04:39:36         Author:azBrian

Json Formatter

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?

Author:azBrian,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24767758/mysql-unix-timestamp-calculation
yy