Skip to main content
Glama
Date Math – Business Days, Holidays & Time Zones

Date Math – Business Days, Holidays & Time Zones

Date difference

date_diff
Read-onlyIdempotent

Calculate days, weeks, months, or business days between two dates or datetimes, excluding weekends and public holidays. Use it for age, tenure, countdowns, notice periods, and working days until a deadline.

Instructions

How many days, weeks, months or business days between two dates or datetimes: calendar (Y/M/D), totals, and business days (weekdays in [from, to) minus holidays; pass country to exclude its public holidays). Use for age, tenure, countdowns, notice periods and working days until a deadline. First 25 calls per day are free, then $0.001 per call (x402).

Input Schema

NameRequiredDescriptionDefault
toYesYYYY-MM-DD, or ISO 8601 datetime with Z or offset
fromYesYYYY-MM-DD, or ISO 8601 datetime with Z or offset
countryNoISO 3166-1 alpha-2 country code (207 countries); its public holidays (2000–2050) are excluded from business days
holidaysNoExtra dates excluded from business-day counts (rest days from workdays are always excluded)
workdaysNoWorking days of the week, 0 = Sunday. Default [1,2,3,4,5] (Mon–Fri); e.g. [0,1,2,3,4] for Sun–Thu or [1,2,3,4,5,6] for Mon–Sat

Output Schema

NameRequiredDescriptionDefault
toYes
fromYes
calendarYes
directionYes
total_daysYes
total_hoursNoDatetime inputs only
total_weeksYes
iso_durationYes
business_daysNoWeekdays in [from, to) minus holidays (date inputs only)
total_minutesNo
total_secondsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover read-only/idempotent/closed-world, but the description adds two things they cannot: a cost model (first 25 calls/day free, then $0.001 via x402) and the constraint that business-day counting applies only to date inputs. It does not mention date-ordering behavior if 'to' precedes 'from', which is the main remaining behavioral unknown.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core capability is front-loaded in the first clause, followed by mechanics, use cases, and pricing in a logical order. The first sentence is heavily parenthetical and dense, but no sentence is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, return values need not be explained; the description still covers units, business-day rules, holiday handling, cost, and the date-only restriction on business-day counts. That is enough for an agent to call this correctly given five fully documented parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the half-open [from, to) interval, workdays default, and country holiday scope are already documented in the schema. The description largely restates those semantics ('weekdays in [from, to) minus holidays; pass country to exclude its public holidays') without adding format or edge-case detail beyond them.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and result ('how many days, weeks, months or business days between two dates or datetimes') and enumerates the output modes (calendar Y/M/D, totals, business days). It implicitly contrasts with the inverse sibling date_add, but never names any sibling explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete use cases — age, tenure, countdowns, notice periods, working days until a deadline — which clearly frames the intended context. It stops short of saying when NOT to use it or naming an alternative tool such as date_add or business_day.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.