SELECT * FROM contrat WHERE idEnteteContrat=268


SELECT * FROM entetecontrat WHERE idPolice=62
 AND id=268
 
 SELECT 
  `fn_exercice_adherent`(`a`.`idAdherent`,`b`.`dateEffet`)  AS `exercieReference`,
  `fn_id_entetecontrat_police`(`a`.`idPolice`,`a`.`dateEffet`)  AS `idEntetecontrat`,
  (TO_DAYS(CURDATE()) - TO_DAYS(`b`.`dateEntree`)) AS `anciennete`,
  (TO_DAYS(CURDATE()) - TO_DAYS(`a`.`dateEntree`)) AS `anciennetebeneficiaire`,
  (TO_DAYS(CURDATE()) - TO_DAYS(`b`.`dateEntree`)) AS `ancienneteadherent`,
  
  
  
JOIN entetecontrat C ON (C.idPolice=A.idPolice)

AND C.id = fn_id_entetecontrat_police_courant(C.idPolice);


-- DATE COMPTEABLE
SELECT DATE_FORMAT(LAST_DAY('2022-12-13'), "%d/%m/%Y");

