Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.
Last reviewed:
Date arithmetic relies on serial numbers: subtracting two dates gives the number of days between them. Wrong results occur when one or both values are text strings masquerading as dates, when time-of-day components add fractional days, or when DATEDIF arguments are in the wrong order.
=DATEDIF(B2,A2,"D")=DATEDIF(A2,B2,"D")DATEDIF requires the start date as the first argument and the end date as the second. If they are reversed and end_date < start_date, DATEDIF returns #NUM!. Swapping the arguments so start_date comes first fixes it.
Edit the grid or formula, then run it through a real spreadsheet engine — no signup.
Sample data — click any cell to edit
Stop hunting errors by hand.
Upload your spreadsheet and the Auditor flags every Wrong date and broken formula at once — or paste this one formula and get the fix explained.
One or both cells contain a date-time value — the integer part is the date, the fractional part is the time. Use =INT(end_date) - INT(start_date) to subtract dates only, or =DAYS(end_date, start_date) which works on the integer date portion.
"M" returns the total number of complete months between the two dates across all years (e.g., 14 months). "YM" returns the number of complete months in the partial year only, ignoring the full years (e.g., 2 months of the extra partial year). Use "YM" only when constructing a '2 years, 2 months' display.
=DAYS(end_date, start_date) and =end_date - start_date give the same result when both cells contain real date serial numbers. DAYS() is slightly more readable and ignores time components in Google Sheets. Use simple subtraction when both values are confirmed date serials.
Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.
Last reviewed: