# Calibration Due and Overdue List SQL Query Generator

> Source: https://netray.co/tools/calibration-due-list-sql-query-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in your table and column names and get SQL for overdue, due soon and never-calibrated gages.

## Category

developer

## Industry

Discrete Manufacturing

## Audience

- ERP admin
- Quality engineer
- Metrologist

## Tool

**Kind:** template

**Output:** code

**Language:** sql

**Fields:**

#### Gage master table

**Key:** table

**Type:** text

**Default:** gage_master

**Help:** Generic name, replace with your table

#### Gage ID column

**Key:** id_col

**Type:** text

**Default:** gage_id

#### Last calibration date column

**Key:** last_col

**Type:** text

**Default:** last_cal_date

#### Interval (days) column

**Key:** interval_col

**Type:** text

**Default:** cal_interval_days

#### Status column

**Key:** status_col

**Type:** text

**Default:** status

#### Location column

**Key:** location_col

**Type:** text

**Default:** location

#### Due soon window (days)

**Key:** window

**Type:** number

**Default:** 30

#### Grace period (days)

**Key:** grace

**Type:** number

**Default:** 0

**Blocks:**

#### Overdue gages (PostgreSQL or Oracle date arithmetic)

**Body:** SELECT g.{{id_col}},
       g.{{location_col}},
       g.{{last_col}} + g.{{interval_col}} AS due_date,
       CURRENT_DATE - (g.{{last_col}} + g.{{interval_col}} + {{grace}}) AS days_overdue
FROM {{table}} g
WHERE g.{{status_col}} = 'ACTIVE'
  AND g.{{last_col}} IS NOT NULL
  AND g.{{last_col}} + g.{{interval_col}} + {{grace}} < CURRENT_DATE
ORDER BY days_overdue DESC;

#### Due within the window

**Body:** SELECT g.{{id_col}},
       g.{{location_col}},
       g.{{last_col}} + g.{{interval_col}} AS due_date
FROM {{table}} g
WHERE g.{{status_col}} = 'ACTIVE'
  AND g.{{last_col}} IS NOT NULL
  AND g.{{last_col}} + g.{{interval_col}} >= CURRENT_DATE
  AND g.{{last_col}} + g.{{interval_col}} <= CURRENT_DATE + {{window}}
ORDER BY due_date;

#### Never calibrated

**Body:** SELECT g.{{id_col}}, g.{{location_col}}
FROM {{table}} g
WHERE g.{{status_col}} = 'ACTIVE'
  AND g.{{last_col}} IS NULL;

#### SQL Server variant of the overdue test

**Body:** -- SQL Server uses DATEADD instead of date plus integer
SELECT g.{{id_col}},
       DATEADD(day, g.{{interval_col}}, g.{{last_col}}) AS due_date
FROM {{table}} g
WHERE g.{{status_col}} = 'ACTIVE'
  AND DATEADD(day, g.{{interval_col}} + {{grace}}, g.{{last_col}}) < CAST(GETDATE() AS date);

**Notes:** Table and column names are generic placeholders. Replace them with those in your ERP, QMS or CMMS, for example your gage or equipment master. Date arithmetic differs by database, and some systems store intervals in months. Test on a copy before scheduling it as a report.

## Content

**Intro:** Every calibration program needs a reliable list of what is overdue, what falls due soon and what has never been calibrated. This generator writes those queries for a gage master table so you can plug in your own table and column names.

**Sections:**

#### How to use it

**Body:** Enter the table and column names from your database, a due-soon window and an optional grace period. Copy the query that fits your database. The first block lists active gages whose due date, last calibration plus interval plus grace, has passed. The second lists gages coming due. The third finds active gages with no calibration date, a common audit finding.

#### Design choices that matter

**Body:** Due dates computed from the last calibration date plus the interval are simple, but many programs use fixed month-end due dates, or a due date stored on the record. If your system stores the next due date, use it directly and drop the arithmetic. Decide whether grace is allowed at all; under ISO/IEC 17025 and ISO 10012 style systems, using an overdue gage is a nonconformance that may require an impact review.

**Bullets:**

- Filter on status so retired or out-of-service gages do not clutter the list
- Check how your interval is stored: days, months or a calendar rule
- Use the records of the last calibration, not the scheduled date

#### Using it in an ERP

**Body:** Many ERP quality or maintenance modules hold calibration data as equipment records with a calibration plan and task. Table names differ by system and version, so look up the real schema before running anything. Run the query against a read-only reporting copy, and confirm the user account has only select access.

#### Common mistakes

**Body:** Counting the gage as calibrated when the work order was created rather than when it was completed, ignoring time zones on date columns, and forgetting that a gage failing calibration is not the same as being overdue are frequent errors. Add a join to results if you need to flag out-of-tolerance findings.

**Cta:** If you want these lists as a scheduled report or an alert from your ERP, we can build that against your actual schema.

**Faq:**

#### Will this run in my ERP unchanged?

**Answer:** No. The table and column names are placeholders. Map them to your equipment or gage tables and check the date arithmetic for your database. Treat the output as a starting point and test it first.

#### How do I handle intervals in months?

**Answer:** Use your database's add-months function, such as ADD_MONTHS in Oracle or DATEADD(month, ...) in SQL Server, and replace the day arithmetic. Month-based intervals avoid drift for calendar-based programs.

#### Should a grace period be used?

**Answer:** Only if your procedure allows it. Some organisations permit a short grace for non-critical gages with documented approval. For critical or customer-mandated gages, a gage past due is out of use until calibrated.

#### Can I send this by email each week?

**Answer:** Yes. Most databases and ERP systems can schedule a query and send the results. Include the gage owner so the right person is notified.

## Search terms

calibration due list sql, overdue calibration query, gage master table sql, calibration due report query, equipment calibration sql server, calibration schedule sql oracle, calibration reminder query, gage calibration status report

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
