# ISO date compare

`iso-date-compare` · version 1.0.0 · Dates & times (UTC, ISO 8601) · free, no key needed

Compare two YYYY-MM-DD calendar dates and return -1, 0, or 1.

**Use when you need to: iso date compare · compare two dates · date ordering.**

## Supported

- iso date compare
- compare two dates
- date ordering

## Not supported

- locale collation
- datetime comparison
- timezones

## Behavior

- a and b are strict YYYY-MM-DD proleptic Gregorian UTC calendar dates with year 0001-9999.
- Comparison is numeric on the civil day serial, not lexicographic on the string (both agree for zero-padded YYYY-MM-DD, but lexicographic is not the defined rule).
- Returns -1 if a is before b, 0 if equal, 1 if a is after b.

## Input

- `a` (string, required): min length 10; max length 10; pattern `^\d{4}-\d{2}-\d{2}$`
- `b` (string, required): min length 10; max length 10; pattern `^\d{4}-\d{2}-\d{2}$`

## Output

- `comparison` (one of -1, 0, 1, required)

## Limits

- year min: 1
- year max: 9999

## Example

Request input:

```json
{
  "a": "2026-01-01",
  "b": "2026-01-02"
}
```

Response:

```json
{
  "result": {
    "comparison": -1
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "iso-date-compare",
  "version": "1.0.0",
  "input": {
    "a": "2026-01-01",
    "b": "2026-01-02"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/iso-date-compare/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":"2026-01-01","b":"2026-01-02"}'
```

The machine-readable contract is at [/v1/tools/iso-date-compare/versions/1.0.0](/v1/tools/iso-date-compare/versions/1.0.0).

### CLI

```sh
node cli.mjs run iso-date-compare 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [ISO date business days count](/tools/iso-date-business-days-count): Count the business days in an inclusive date range, skipping caller-supplied weekend weekdays and holidays.
- [ISO date range list](/tools/iso-date-range-list): Enumerate the dates in an inclusive [start, end] range stepped by a whole number of days.
- [ISO date weekday occurrences in range](/tools/iso-date-weekday-occurrences-in-range): List every date within an inclusive date range that falls on a given ISO weekday.
- [ISO date-time compare](/tools/iso-datetime-compare): Compare two strict UTC ISO-8601 datetimes and return -1, 0, or 1.
- [ISO date age](/tools/iso-date-age): Compute the calendar-aware elapsed years, months, and days between a birth date and an as-of date.
- [ISO date difference](/tools/iso-date-difference): Whole days from start to end as a canonical integer string (end - start).
