How to calculate Days Payable Outstanding (DPO)
Days payable outstanding is the average number of days a company takes to pay its suppliers.
Formula
DPO = (accounts payable ÷ cost of goods sold) × days in periodSQL query
This example assumes: bills(id, vendor_id, received_at, amount, paid_at), sales(sold_at, cogs). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.
WITH ap AS (
SELECT SUM(amount) AS payable FROM bills
WHERE received_at <= DATE '2026-09-30'
AND (paid_at IS NULL OR paid_at > DATE '2026-09-30')
), c AS (
SELECT SUM(cogs) AS cogs FROM sales
WHERE sold_at >= DATE '2026-07-01' AND sold_at <= DATE '2026-09-30'
)
SELECT ap.payable / NULLIF(c.cogs, 0) * 92 AS dpo_days
FROM ap, c;Common mistakes that make Days Payable Outstanding (DPO) wrong
- A high DPO helps cash but can harm supplier relationships and early-payment discounts.
- Use the same period for payables and COGS.
- Services with no COGS need purchases as the denominator.
Ask for Days Payable Outstanding (DPO) in plain English
Instead of writing the query yourself, you can type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. It does not replace your judgement about the definition: check that the query matches the formula your business uses.
- What is our DPO this quarter?
- Which vendors do we pay slowest?