I need help with a query what I want is that I need to calculate the months of a worker of a company and add them with all the other contracts he had.
EJ: If you started working on a date like 06/15/2016 until 06/15/2018 (24 months), but you suddenly decided to retire from That company and then later decided to return and now has a contract from 04/16/2018 to 04/16/2019 (12 months) I need to add all those months for each worker (36 months). Your answer would be very helpful.
This is what I have but I can not specify what I need:
<?php
$query=$obj->post_ejecutar("SELECT * FROM datoscontractuales WHERE estado NOT IN (4, 5, 6)");
while ($row=pg_fetch_array($query)) {
$años=(strtotime($row["fecinicio"])-strtotime($row["fecfin"]))/(30*60*60*24);
//La función abs lo que hace es sacar el valor absoluto de el valor recibido
$años=abs($años);
//Redondea un número decimal
$años=floor($años);
echo $años;
}
?>