Forum Discussion
calculer le nombre de mois entre 2 dates dans Excel office 365
J'essaye de savoir combien de mois il y a entre 2 dates dans Excel pour office 365 et tout ce qu'on me propose c'est d'utiliser une vieille fonction qui n'apparait pas dans les fonctions de Excel: Dateif().
Cette fonction est mal documenté et ne fonctionne pas. Elle donne toujours l'erreur #nom?.
Comment faire pour simplement calculer le nombre de mois entre 2 dates... C'est quelque chose de standard non ? Ca devrait être simple non ?
Merci
5 Replies
- Riny_van_EekelenPlatinum Contributor
François_Soucy The function is DATEDIF, and yes it has it's weaknesses. Documentation in the attached link. Alternatively, just deduct the start date from the end date and divide the result be 30.4167 (that is, the approximate average number of days per month in any given year).
https://support.microsoft.com/en-us/office/datedif-function-25dba1a4-2812-480b-84dd-8b32a451b35c
- mathetesSilver Contributor
Riny_van_Eekelen wrote just deduct the start date from the end date and divide the result be 30.4167 (that is, the approximate average number of days per month in any given year).
"approximate"!!??-- how many more decimal places would you need, my friend, before it's the precise average? [smiley face]
- Riny_van_EekelenPlatinum Contributor
mathetes Haha! As you know, one month may be 28, 29, 30 or 31 days, but never 30,4167. That's why I used the word "approximate". But it's good enough to the "how many months" calculation.
- mathetesSilver Contributor
YOu're right that it's poorly documented. But it does work:
=DATEDIF(earlier_date,later_date,"m")
It returns #NUM if the dates are reversed. So have the earlier of the two dates first in the function.