How to Track Inventory Expiration Dates in Google Sheets with Email Alerts (Lots, FEFO, 2026)

Kitchens, cafés, food pantries, clinics, labs, salons and small shops often keep stock with an expiry date in a spreadsheet: food and drinks, medical and first-aid supplies, reagents, cosmetics, chemicals. The hard part isn't writing the date down, it's noticing in time that a box at the back of the store room runs out next week, and using the oldest stock first. This guide sets up one row per lot, color-codes what is about to expire, builds a “use this first” list, and adds a free Apps Script that emails each person one list of their lots that are close to expiring or already expired while still in stock.

If you already use an inventory or point-of-sale system with lot and expiry tracking, use its alerts. This guide is for when the sheet is the system. For equipment warranties and service dates, see the warranty expiration tracker and maintenance schedule reminders.

Step 1: a Lots tab with one row per lot

Track lots, not products. Two deliveries of the same item usually expire on different dates, so each delivery (or each batch with its own date) gets its own row. Name the tab Lots. The script finds columns by their header, so the order is up to you, but the formulas below assume A to H:

ColHeaderWhat goes in it
AItemWhat it is, e.g. “Oat milk 1 L”, “Sterile gauze 4x4”
BLotOptional lot or batch number from the label
CLocationOptional: walk-in cooler, shelf 2, van 1
DQtyHow many are left. 0 stops alerts; blank counts as still in stock.
EExpiry dateA real date (see month-only dates below)
FNotifyOptional email of whoever looks after this stock. Blank = the script owner, or DEFAULT_TO.
GStatusBlank while in stock. Used up, Sold, Discarded, Disposed, Returned, Written off or Donated stop alerts.
HSent logLeave empty; the script records what it sent

Add a helper column I, Days left, filled down from row 2: =IF(E2="","",E2-TODAY()). Negative means expired. Format column E as a date (Format › Number › Date) and give Status a Data › Data validation dropdown so the stop words are spelled the way the script expects.

Month-only dates. Labels often say only a month, like “EXP 03/2027”. That usually means the end of the month, but check the manufacturer's or supplier's convention for your products. If you type the label into column J, first formatted as Format › Number › Plain text so Sheets doesn't turn it into a date, this turns it into the last day of that month: =IF(J2="","",EOMONTH(DATE(RIGHT(J2,4),LEFT(J2,2),1),0)). Copy the result and paste it into Expiry date as a value.

“Use within N days of opening.” Some products get a shorter life once opened. Put the opened date in column K and use the earlier of the two dates: =IF(K2="",E2,MIN(E2,K2+28)), with 28 replaced by the product's own number. Again, paste it into Expiry date as a value, or point the script at that column by naming its header Expiry date instead.

Step 2: see what is expiring and what to use first

Select A2:I, open Format › Conditional formatting, choose Custom formula is, and add these rules in this order:

Custom formulaColorMeaning
=OR(AND(ISNUMBER($D2),$D2<=0),REGEXMATCH(LOWER($G2),"^(used up|sold|sold out|discarded|disposed|returned|written off|donated)$"))Grey textGone, no alerts
=AND(ISNUMBER($E2),$E2<TODAY())RedExpired and still in stock
=AND(ISNUMBER($E2),$E2>=TODAY(),$E2<=TODAY()+30)AmberExpires in the next 30 days

Conditional formatting stops at the first matching rule, so lots that are gone stay grey even after their date passes. For a “use first” list, the oldest-expiring lot of each item still in stock (first expired, first out, often called FEFO), put this on a summary tab:

=QUERY(Lots!A2:G,
  "select A, min(E), sum(D) where A is not null and E is not null and (D > 0 or D is null)" &
  " and not G matches '(?i)used up|sold|sold out|discarded|disposed|returned|written off|donated'" &
  " group by A order by min(E) label A 'Item', min(E) 'Use first (expires)', sum(D) 'In stock'", 0)

To see which lot that is and where it sits, list every lot in stock sorted by item and then by expiry; the first row of each item is the one to pick:

=SORT(FILTER(Lots!A2:E, Lots!A2:A<>"", ISNUMBER(Lots!E2:E),
  (Lots!D2:D="")+(Lots!D2:D>0),
  NOT(REGEXMATCH(LOWER(Lots!G2:G), "^(used up|sold|sold out|discarded|disposed|returned|written off|donated)$"))),
  1, TRUE, 5, TRUE)

And how much of one item expires in the next 30 days (item name in A2 of the summary tab):

=SUMIFS(Lots!D2:D, Lots!A2:A, A2, Lots!E2:E, ">="&TODAY(), Lots!E2:E, "<="&TODAY()+30)

Step 3: email alerts before and after the expiry date

Google Sheets doesn't send email when a date arrives; its notification rules react to edits, not to the calendar. A short Apps Script with a daily trigger does it. Open Extensions › Apps Script, paste this and save. Then:

  1. Run sendExpiryAlerts once and approve the permissions. PREVIEW is true, so every email goes to you, with the real recipient in the subject, and nothing is logged.
  2. Read the preview emails. When they look right, set PREVIEW = false and save.
  3. Add the trigger: Triggers › Add trigger › sendExpiryAlerts › Time-driven › Day timer, for example 6 to 7 AM, before the first shift.
/**
 * Expiration alerts from a "Lots" tab: one row per lot or batch.
 * Headers used (any order): Item, Lot, Location, Qty, Expiry date,
 *   Notify, Status, Sent log. Only Item, Expiry date and Sent log are required.
 * Each person gets one email per run listing the lots that are about to
 * expire or have expired while still in stock. Qty 0, or a Status such as
 * Used up / Discarded, stops a row.
 */
const SHEET_NAME   = 'Lots';
const REMIND_DAYS  = [60, 30, 7, 0]; // days before the expiry date (0 = the day itself)
const EXPIRED_DAYS = [1, 7];         // days after it, while the lot is still in stock
const DEFAULT_TO   = '';             // used when Notify is blank; blank = you
const STOP_STATUS  = /^(used up|sold|sold out|discarded|disposed|returned|written off|donated)$/i;
const PREVIEW      = true;           // true: everything goes to you, nothing is logged
const MAX_EMAILS   = 50;             // safety cap per run (one email per person)

const SUBJECT = 'Expiring stock: {{Count}} ({{Expired}} expired)';
const INTRO   = 'Hi,\n\nThese lots are close to their expiry date or past it and still in stock:';
const OUTRO   = 'Use or move the soonest-expiring stock first. When a lot is gone, set Qty to 0 or Status to Used up / Discarded and the alerts stop.';

function sendExpiryAlerts(now) {
  const lock = LockService.getDocumentLock();
  if (!lock.tryLock(30000)) return;  // another run is still going
  try {
    // A time-driven trigger passes an event object, so only use a real Date.
    return alertExpiring_(now instanceof Date ? new Date(now) : new Date());
  } finally {
    lock.releaseLock();
  }
}

function alertExpiring_(now) {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName(SHEET_NAME);
  if (!sh) throw new Error(`No tab named ${SHEET_NAME}.`);
  const rows = sh.getDataRange().getValues();
  const head = rows[0].map((h) => String(h).trim());
  const col  = (name) => head.indexOf(name);
  const c = { item: col('Item'), lot: col('Lot'), where: col('Location'), qty: col('Qty'),
              exp: col('Expiry date'), to: col('Notify'), status: col('Status'), log: col('Sent log') };
  if ([c.item, c.exp, c.log].includes(-1)) {
    throw new Error('Need Item, Expiry date and Sent log columns.');
  }

  // Count days in the spreadsheet's own time zone (File > Settings),
  // so a script project set to another zone can't shift alerts by a day.
  const tz     = ss.getSpreadsheetTimeZone();
  const ymd    = (d) => Utilities.formatDate(d, tz, 'yyyy-MM-dd');
  const dayNum = (d) => Date.UTC(...ymd(d).split('-').map((x, i) => +x - (i === 1 ? 1 : 0))) / 86400000;
  const today  = dayNum(now);
  const isDate = (v) => v instanceof Date && !isNaN(v);
  const EMAIL  = /^[^\s@,;]+@[^\s@,;]+\.[^\s@,;]+$/;
  const me     = Session.getEffectiveUser().getEmail();
  // One list of steps: 30 = 30 days before, -7 = 7 days after expiry.
  const steps  = REMIND_DAYS.concat(EXPIRED_DAYS.map((n) => -n));

  const byPerson = {};
  let badEmail = 0;
  for (let r = 1; r < rows.length; r++) {
    const row  = rows[r];
    const text = (i) => (i === -1 ? '' : String(row[i]).trim());
    if (STOP_STATUS.test(text(c.status))) continue;
    const qty = c.qty === -1 ? '' : row[c.qty];
    if (typeof qty === 'number' && qty <= 0) continue;  // used up; blank Qty counts as in stock
    const exp = row[c.exp];
    if (!isDate(exp) || text(c.item) === '') continue;
    const left = dayNum(exp) - today;  // negative = expired
    // The one step that fits today: no pile of earlier ones after a gap.
    // Once a lot has expired, only the EXPIRED_DAYS steps apply.
    const hit = steps.filter((s) => left <= s && (left >= 0 || s < 0)).sort((a, b) => a - b)[0];
    if (hit === undefined) continue;
    const sent = String(row[c.log] || '').split(';').filter(String);
    // Keyed to the expiry date: correcting the date restarts the alerts.
    const key = `E${ymd(exp)}@${hit}`;
    if (sent.includes(key)) continue;
    const to = (text(c.to) || DEFAULT_TO || me).toLowerCase();
    if (!EMAIL.test(to)) { badEmail++; console.log(`Row ${r + 1}: check the Notify email`); continue; }
    const when = left > 1 ? `expires in ${left} days` : left === 1 ? 'expires tomorrow' :
                 left === 0 ? 'expires today' : left === -1 ? 'EXPIRED yesterday' : `EXPIRED ${-left} days ago`;
    const item = {
      r: r + 1, left, where: text(c.where),
      line: `- ${text(c.item)}` +
            (text(c.lot) ? ` (lot ${text(c.lot)})` : '') +
            (qty !== '' ? `, qty ${qty}` : '') +
            (text(c.where) ? `, ${text(c.where)}` : '') +
            `: ${Utilities.formatDate(exp, tz, 'EEE, MMM d, yyyy')} (${when})`,
      log: sent.concat(key).slice(-12).join(';'),
    };
    (byPerson[to] = byPerson[to] || []).push(item);
  }

  // People with the most urgent lot first, in case the quota runs out.
  const groups = Object.keys(byPerson).map((to) => {
    const items = byPerson[to].sort((a, b) => a.left - b.left || a.where.localeCompare(b.where) || a.r - b.r);
    return { to, items, worst: items[0].left };
  }).sort((a, b) => a.worst - b.worst);

  let sent = 0;
  for (const g of groups) {
    if (sent >= MAX_EMAILS || MailApp.getRemainingDailyQuota() < 1) break;
    const expired = g.items.filter((i) => i.left < 0).length;
    const subject = SUBJECT.replace('{{Count}}', g.items.length + (g.items.length === 1 ? ' lot' : ' lots')).replace('{{Expired}}', expired);
    const body = [INTRO, '', ...g.items.map((i) => i.line), '', OUTRO, '', `Sheet: ${ss.getUrl()}`].join('\n');
    MailApp.sendEmail({
      to: PREVIEW ? me : g.to,
      subject: PREVIEW ? `[PREVIEW to ${g.to}] ${subject}` : subject,
      body,
    });
    sent++;
    if (!PREVIEW) {
      // Log right after each email, so a crash can't cause a repeat.
      g.items.forEach((i) => sh.getRange(i.r, c.log + 1).setValue(i.log));
      SpreadsheetApp.flush();
    }
  }
  const result = { sent, left: groups.length - sent, badEmail, preview: PREVIEW };
  console.log(JSON.stringify(result));
  return result;
}

How it behaves:

Tips

Want alerts without maintaining a script? SheetReminders (disclosure: we make it) is a Google Sheets add-on that watches a date column, such as Expiry date, and emails the right person on time: several reminders per date (like 30, 7 and 0 days before), reminders after a date for items still open, personalized messages with {{Column name}} and {{Days left}}, a digest mode with one email per person, skipping rows marked as finished, and a sent log written back to the row. Sheet data stays inside your Google account and it uses narrow scopes. 14-day free trial, no credit card required. It is live on the Google Workspace Marketplace.
See SheetReminders
Short on time? Watch the 50-second version

Related Google Sheets guides

Instructions refer to Google Sheets and Apps Script as they worked on November 14, 2026. Not affiliated with Google or any other vendor named here. Google Sheets and Google Docs are trademarks of Google LLC. Features change, so verify in your own account. This is not food safety, pharmacy or regulatory advice. Questions or corrections: hello@loomwise.app.