Sub topic 2
Weekdays and week numbers
This chapter assumes you can enter formulas, use cell references, and apply number formats. It also assumes that Sheets stores each date as a serial number, where whole numbers are days. Because of that, subtracting one date from another returns a count of days.
Finding the weekday and week number
WEEKDAY returns a number for the day of the week. Its second argument sets the numbering. With type 2, Monday is 1 and Sunday is 7.
=WEEKDAY(A2, 2)WEEKNUM returns the week of the year and counts weeks from Sunday by default. ISOWEEKNUM follows the ISO 8601 standard, which starts weeks on Monday. Under that standard, week 1 is the week that contains the year's first Thursday.
=ISOWEEKNUM(A2)Adding and subtracting dates
Because dates are day counts, you add days with + and find the gap with -.
=A2 + 30
=B2 - A2The first formula returns a date 30 days after A2. The second returns a number of days. If Sheets applies a date format to the result, change the format to Number so the count displays correctly.
Working with times of day and durations
A time is a fraction of a day, so 12:00 is stored as 0.5. When A2 and B2 hold date-times, subtraction returns days. Multiply by 24 to get hours.
=(B2 - A2) * 24For durations longer than 24 hours, apply the custom format [h]:mm. A plain h:mm format wraps back to zero after 24 hours.
Converting between text and dates
Text that looks like a date is not a date, so date functions may fail or return wrong results. DATEVALUE and TIMEVALUE convert text into numbers that Sheets can calculate with. TEXT does the reverse and returns a text label.
=DATEVALUE("2026-11-28")
=TIMEVALUE("14:30")
=TEXT(A2, "yyyy-mm-dd")| Function | Direction | Result type |
|---|---|---|
| DATEVALUE | Text to date | Date (day count) |
| TIMEVALUE | Text to time | Time (fraction of a day) |
| TEXT | Date to text | Text |
Exercise
A2 holds 2026-11-28 08:00 and B2 holds 2026-11-30 17:30. Which formula returns the elapsed hours?
Show answer
=(B2 - A2) * 24, which returns 57.5.