Sub topic 14
Volatile functions and when they recalculate
This chapter assumes you can enter formulas, use relative and absolute references, and already know that Sheets stores dates as serial numbers. It also assumes you have used TODAY and NOW from the earlier chapter on creating dates. Here you learn when those functions refresh, why the result of a formula can change without anyone touching its cell, and how to keep a date fixed when you need it fixed.
What "volatile" means
Most formulas are recalculated only when something they depend on changes. If C2 contains =A2+B2, Sheets recomputes it when A2 or B2 changes. A volatile function has no such dependency. Its result can differ each time it is evaluated, so Sheets recalculates it more often.
The volatile functions you will meet most often are:
| Function | Returns | Why it is volatile |
|---|---|---|
| `TODAY()` | The current date | The date changes at midnight |
| `NOW()` | The current date and time | The time changes continuously |
| `RAND()` | A random decimal from 0 up to 1 | A new number each evaluation |
| `RANDBETWEEN(low, high)` | A random whole number | A new number each evaluation |
RAND and RANDBETWEEN are not date functions, but they behave the same way. You will often combine them with dates, for example when building test data.
A formula that references a volatile cell is recalculated too. If D2 is =TODAY() and E2 is =D2+30, then E2 refreshes whenever D2 does. The effect spreads down the whole chain of dependent cells.
When Sheets recalculates
Sheets recalculates volatile functions in these situations:
- When the spreadsheet is opened or reloaded.
- When a cell in the spreadsheet is edited. Any edit counts, even in an unrelated sheet tab.
- On a schedule, if you turn one on in the settings.
The schedule is under File > Settings > Calculation. The Recalculation option has three values:
- On change: the default. Volatile functions refresh only when the file is opened or edited.
- On change and every minute.
- On change and every hour.
Under the default setting, a sheet left open and untouched shows a stale NOW(). The displayed time can be many minutes old. The value corrects itself on the next edit or reload.
The calculation setting belongs to the whole spreadsheet file, not to a single sheet tab or formula. Anyone with edit access can change it.
Seeing it happen
Put this in A1:
=NOW()Format A1 as Date time from Format > Number. Then put this in B1:
=A1 - TODAY()B1 shows the fraction of the day that has passed since midnight, in the spreadsheet's time zone. Format it as a plain number to see a value such as 0.5 at midday. Type anything into D1. Both A1 and B1 update, even though neither formula refers to D1.
To see random values change the same way, put =RANDBETWEEN(1, 100) in a cell and type into any other cell. The number changes on each edit.
Consequences you should plan for
Results are not a record
A formula such as =TODAY() does not record the day a row was created. Tomorrow it shows tomorrow's date. If you use TODAY to stamp an order date, every order silently takes on the current date.
The same happens with ages and durations. This formula gives the age of a ticket in days:
=TODAY() - A2This is correct as a live age. It is wrong as a stored value. Next week the cell shows a different number, and any report that was exported or printed last week no longer matches the sheet.
Random values reshuffle
=TODAY() + RANDBETWEEN(1, 30) produces a new date on every edit. If you need sample dates that stay put, generate them once and then convert them to static values (see below).
Long dependency chains cost time
If thousands of cells depend on TODAY(), each refresh recalculates all of them. A common mistake is writing TODAY() into every row, as in =IF(B2 < TODAY(), "Overdue", "OK") on 20,000 rows. Put =TODAY() in one cell, name it or reference it with an absolute reference such as $G$1, and use that cell in the rows:
=IF(B2 < $G$1, "Overdue", "OK")This changes only the cost of the evaluation, not the result. It also gives you a single place to override the date when you want to test the sheet, for example by typing 2026-12-31 into G1.
Other tools see the last calculated value
Scripts, other spreadsheets that import from this one, and published or emailed copies read the values from the most recent recalculation. Do not assume an exact refresh time. If another process depends on today's date being correct, have that process compute the date itself.
Dates inside text and queries
Volatile results also flow through text. A QUERY that filters on today's date needs the date converted to text in the format the query language expects:
=QUERY(A1:C, "select * where A >= date '" & TEXT(TODAY() - 7, "yyyy-mm-dd") & "'", 1)The query refreshes whenever TODAY() does. Here the TEXT function returns text, so it only works because QUERY receives a string. The "Converting between text and dates" chapter covers this function in more detail.
Freezing a value
When you need a date or time that stays fixed, you have three options.
Keyboard shortcuts
Select a cell and press:
Ctrl + ;to insert the current date as a fixed value.Ctrl + Shift + ;to insert the current time as a fixed value.Ctrl + Alt + Shift + ;to insert both. On Mac, useCmdin place ofCtrl.
These write a plain date or date-time value, not a formula. It never changes after that.
Paste values only
To freeze a formula result, including random dates:
- Select the cells that contain the formula.
- Copy them with
Ctrl + C. - Paste over the same cells with
Ctrl + Shift + V(paste values only).
The formulas are replaced with their current results. You cannot undo this later except with undo or version history, so keep a copy if the formulas matter.
A timestamp from Apps Script
To record when a row was first filled in, use a script. This simple trigger writes the time into column B whenever a cell in column A of the sheet named Log is edited:
function onEdit(e) {
const range = e.range;
const sheet = range.getSheet();
if (sheet.getName() !== "Log") return;
if (range.getColumn() !== 1 || range.getRow() < 2) return;
// Write a fixed timestamp next to the edited row.
sheet.getRange(range.getRow(), 2).setValue(new Date());
}Open Extensions > Apps Script, paste the function, and save. The value written is a real date-time, not a formula, so it stays unchanged. Format column B as Date time if it appears as a number. The simple onEdit trigger fires on edits made by people in the sheet. It does not fire for changes made by other scripts, so test it with a manual edit. To re-stamp only when the cell was empty, add a check on the existing value of the target cell before writing.
Time zones and volatile results
TODAY and NOW use the spreadsheet's time zone, set under File > Settings > General. They do not use the time zone of each viewer's computer. Two people looking at the same file see the same TODAY(), even if it is already tomorrow where one of them lives. If your file is shared across regions, set the time zone to the one your business uses and say so in the sheet.
Choosing the right approach
| Need | Use |
|---|---|
| A live "days remaining" or "overdue" indicator | `TODAY()` in one control cell, referenced by other formulas |
| The date a record was created | A shortcut, pasted value, or `onEdit` script |
| A clock that stays current in an open sheet | `NOW()` with recalculation set to every minute |
| Test data that does not change | `RAND` or `RANDBETWEEN`, then paste values only |
| A report that must match a past date | A fixed date in a cell, not `TODAY()` |
Troubleshooting
- A date or number keeps changing. Search the sheet for
TODAY,NOW,RANDandRANDBETWEEN. Use Edit > Find and replace, tick Also search within formulas, and search for each name in turn. The change may also come from a cell that depends on one of these. - A time looks stale. The recalculation setting is probably On change. Edit any cell, reload, or switch to a timed option.
- The date is a day off. Check the spreadsheet time zone under File > Settings > General.
- A frozen timestamp still moves. The cell still contains a formula. Click it and look in the formula bar. If it starts with
=, repeat the paste-values step.
Exercise
Column A holds order dates entered as =TODAY() when each order was placed. A manager reports that last month's orders all show today's date. Explain why this happens and how you would fix the existing data and prevent it for new rows.
Show answer
TODAY() is volatile, so each cell is recalculated on open and on every edit and always returns the current date, not the date the formula was entered. The original dates cannot be recovered from the cells, so restore them from version history (File > Version history) or another source. For new rows, enter fixed dates with Ctrl + ; or use an onEdit Apps Script that writes new Date() as a value. To freeze dates that are correct right now, copy the cells and paste them back with Ctrl + Shift + V.
Exercise
A sheet has 5,000 rows, each with =IF(C2 < TODAY(), "Overdue", "OK"). Rewrite the setup so that TODAY() is evaluated once, and name one benefit besides speed.
Show answer
Put =TODAY() in a single cell such as G1 and change each row to =IF(C2 < $G$1, "Overdue", "OK"). The benefit is that you can overwrite G1 with any test date, for example 2026-12-31, to check how the sheet will look on another day, then restore =TODAY().