Day 7 — Working with dates
A date in Excel is just a number wearing a costume. Once you know that, date maths stops being frightening.
A date is a number
Every formula on this page runs against the Sales sheet below. The row numbers and column letters are real — F2 really is 165000.
B2 shows 05-Jan-2025. Underneath, Excel stores 45662 — the number of days since 1 January 1900. That is why you can subtract one date from another and get a sensible answer.
Seven days between orders 1001 and 1002. 158 days from the first order to the last. =B2+30 gives the serial number for thirty days later.
Pulling a date apart
WEEKDAY returns 1 for Sunday through 7 for Saturday by default. 5 January 2025 was a Sunday, so this returns 1.
Building a date
Month 13 does not fail — it rolls over into January of the next year. That is genuinely useful for stepping through months in a loop.
TEXT — showing a date the way you want
That last point is exactly what makes =TEXT(B2,"mmm yyyy") so useful for grouping — and so dangerous if you then try to sort by it, because "Apr 2025" sorts before "Jan 2025" alphabetically.
Month-end and month-shifting
EOMONTH(date,0) is the end of the current month, -1 the end of the previous one. These two are the backbone of every monthly MIS: they give you period boundaries that are correct in February and in leap years without you thinking about it.
DATEDIF — the undocumented one
This lesson uses the Staff sheet below.
Amit joined in April 2019, so by 30 June 2025 he has completed 6 years and 2 months. DATEDIF counts completed periods, which is what a service or age calculation actually needs.
TODAY
Grouping sales by month
January 210,000, February 158,000, April 238,600. Combining SUMIFS with DATE and EOMONTH gives you a monthly report that never needs its boundaries adjusted.
Try these yourself
- How many days passed between order 1003 and order 1012?
- Show the date in B5 as
Feb 2025. - Find the last day of the month for order 1009.
- Work out how many complete years Sneha Rao had served by 30 June 2025.
- Total the March 2025 sales using DATE and EOMONTH.
