A database calendar with published exchange-rate days and the missing dates between them

The ECB's history looks like a daily file until you join it to daily business data. It is one row per published day. Weekends and TARGET closing days are absent, and some currencies disappear for years. On the snapshot we tested, 7,141 USD rows covered 10,183 calendar dates. A plain date join left 3,042 payments without a rate.

The fix is not simply 'use the previous row'. Carry a Friday rate through a weekend, yes. Carry an Icelandic króna rate across a 3,335-day suspension, no. Store how old a carried rate is, and make the maximum age part of the query or the data build.

What is actually in eurofxref-hist.csv

The file is wide: Date,USD,JPY,..., one date per row, with N/A where that currency has no rate. A number means units of that currency for 1 EUR. The ECB says it normally publishes around 16:00 CET on working days except TARGET closing days, and says the reference rates are for information; using them as transaction prices is discouraged.

text
snapshot                         1999-01-04 to 2026-11-20
calendar dates, inclusive        10,183
USD observations                  7,141
calendar dates with no USD row    3,042
missing share                    29.87%

3,042 / 10,183 = 0.2986349799

That 29.87% is not an estimate. Imagine one payment on every date in the range: 10,183 payments. JOIN rates ON rates.rate_date = payments.paid_on returns 7,141 and drops 3,042. A left join keeps the payments but leaves 3,042 rate values null.

First turn the wide file into a long table

sql
CREATE TABLE fx_rate_observed (
  rate_date date NOT NULL,
  currency  char(3) NOT NULL,
  per_eur   decimal(20,10) NOT NULL,
  PRIMARY KEY (currency, rate_date)
);

-- The CSV row 2026-11-20,1.1520,179.31,... becomes:
INSERT INTO fx_rate_observed VALUES
  ('2026-11-20','USD',1.1520),
  ('2026-11-20','JPY',179.31);

Use a CSV unpivot step before the database, or let Rates Daily read the wide ECB file and download long CSV or SQL. Do not insert N/A; absence is useful information.

Option 1: build one row per calendar day

A daily table makes the application join boring, which is usually good. Keep the observed date and age beside the carried value. The example below uses a five-day ceiling.

sql
CREATE TABLE fx_rate_daily (
  rate_date date NOT NULL, currency char(3) NOT NULL,
  per_eur decimal(20,10) NOT NULL,
  observed_on date NOT NULL, age_days integer NOT NULL,
  PRIMARY KEY (currency, rate_date),
  CHECK (age_days BETWEEN 0 AND 5)
);

SELECT p.id, p.amount, r.per_eur, p.amount * r.per_eur AS amount_in_currency
FROM payments p
JOIN fx_rate_daily r
  ON r.currency = p.currency AND r.rate_date = p.paid_on;

On the tested snapshot, Rates Daily produced all 10,183 USD dates: 7,141 observed and 3,042 carried. The oldest normal carry is around long holiday weekends. Anything beyond the chosen ceiling stays a gap instead of looking current.

Option 2: an as-of join without materialising days

PostgreSQL

sql
SELECT p.id, p.paid_on, p.amount, r.per_eur, r.rate_date AS observed_on
FROM payments p
LEFT JOIN LATERAL (
  SELECT rate_date, per_eur
  FROM fx_rate_observed
  WHERE currency = p.currency AND rate_date <= p.paid_on
  ORDER BY rate_date DESC LIMIT 1
) r ON p.paid_on - r.rate_date <= 5;

MySQL 8

sql
SELECT p.id, p.paid_on, p.amount, r.per_eur, r.rate_date AS observed_on
FROM payments p
LEFT JOIN LATERAL (
  SELECT rate_date, per_eur FROM fx_rate_observed
  WHERE currency=p.currency AND rate_date<=p.paid_on
  ORDER BY rate_date DESC LIMIT 1
) r ON DATEDIFF(p.paid_on, r.rate_date) <= 5;

SQLite

sql
SELECT p.id, p.paid_on, p.amount,
 (SELECT r.per_eur FROM fx_rate_observed r
  WHERE r.currency=p.currency AND r.rate_date<=p.paid_on
    AND julianday(p.paid_on)-julianday(r.rate_date)<=5
  ORDER BY r.rate_date DESC LIMIT 1) AS per_eur
FROM payments p;

The index order matters: (currency, rate_date) lets each lookup seek to one currency and walk backward to the first eligible date. The daily table trades storage for simpler joins; the as-of form stores less but repeats the lookup. Pick on correctness and workload, then measure on your database.

The ISK hole is why the age limit belongs in the design

text
currency   missing interval             calendar days
ISK        2008-12-15 to 2018-01-31       3,335

The ECB suspended Icelandic króna publication after capital controls and the loss of a reliable market-determined rate. It resumed ISK effective 2018-02-01. Filling that interval would not repair weekends; it would invent nine years of unchanged prices. With a five-day maximum, those dates remain null and visible.

The same rule covers currencies that ended because a country adopted the euro. CYP and MTL stop in 2007, EEK in 2010, LVL in 2013, LTL in 2014 and HRK after 2022. Their last value is not a forever exchange rate. Keep a currency-validity table or let the age ceiling stop the carry.

Derived pegs need the same date and age

The ECB file does not need to contain every currency you bill in. Bahrain officially keeps the dinar at 0.376 BHD per USD. Because the ECB quote is USD per EUR, derive BHD per EUR = USD per EUR × 0.376. If USD/EUR is 1.1520, the result is 1.1520 × 0.376 = 0.433152 BHD per EUR. Copy the USD observed date and age onto the derived row.

sql
INSERT INTO fx_rate_daily
SELECT rate_date, 'BHD', per_eur * 0.376, observed_on, age_days
FROM fx_rate_daily WHERE currency = 'USD';

The checks to keep beside the load

sql
-- Dates still missing for a requested range
SELECT d.rate_date
FROM calendar d LEFT JOIN fx_rate_daily r
  ON r.rate_date=d.rate_date AND r.currency='USD'
WHERE d.rate_date BETWEEN DATE '2026-01-01' AND DATE '2026-12-31'
  AND r.rate_date IS NULL;

-- Never let a carried rate exceed policy
SELECT currency, max(age_days) FROM fx_rate_daily GROUP BY currency;

-- Surface long breaks in observed data
SELECT currency, rate_date,
       rate_date-lag(rate_date) OVER (PARTITION BY currency ORDER BY rate_date) AS gap
FROM fx_rate_observed;

Also record the source file's last date. A perfectly filled daily table can still be stale because the import stopped running. Alert when the newest observed date is older than the publication schedule you expect.

A practical default

For reports and payment normalisation, we would build the daily table once, carry at most five calendar days, retain observed_on and age_days, and reject anything older. For occasional analysis, use the as-of join with the same ceiling. In both cases, aggregate after the join and count null rates before trusting the total.

Related: several currencies in one SQL table covers minor units and rate direction; a calendar table in SQL builds the date spine used by the gap check.

Drop the ECB history into Rates Daily, choose currencies and a maximum age, then download a long CSV or SQL for PostgreSQL, MySQL 8 or SQLite. It runs in your browser.

Open Rates Daily

Sources and snapshot

ECB, Euro foreign exchange reference rates and framework; ECB Governing Council, ISK publication resumed effective 1 February 2018; Central Bank of Bahrain, monetary policy and the 0.376 BHD/USD peg. File figures are from the ECB history snapshot ending 2026-11-20, tested by Rates Daily on 2026-11-23. The SQL illustrates join semantics; no performance timings are claimed.